34,590
社区成员
发帖
与我相关
我的任务
分享
update your_table
set col1 = NULL
where replace(col1,' ','') = ''
create table #( i varchar(10))
insert # select ' '
insert # select 'd'
update #
set i=nullif(ltrim(i),'')
select * from #
i
----------
NULL
d
(2 行受影响)
replace(字段,' ','')
--select
select null as col from tb where col = ' ' or replace(col,' ','') = '' or len(replace(col,' ','')) = 0
--update
update tb set col is null where col = ' ' or replace(col,' ','') = '' or len(replace(col,' ','')) = 0
create table #( i varchar(10))
insert # select ' '
select nullif(ltrim(i),'') as i from #
i
----------
NULL
(1 行受影响)