怎样将sql数据库字段中的NULL都替换为空

a3155792 2011-08-26 08:47:38
怎样将sql数据库字段中的NULL都替换为空。给个sql语句把


update record set land_user=''where land_user= null我试了这样的都不对啊
...全文
1648 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
geniuswjt 2011-08-31
  • 打赏
  • 举报
回复
+1[Quote=引用 4 楼 maco_wang 的回复:]
SQL code
--判断null用is不是=

--如果不更新,在取数据的时候用
select isnull(land_user,'') as land_user from record
--也是可以的
[/Quote]
romi17 2011-08-31
  • 打赏
  • 举报
回复
[Quote=引用楼主 a3155792 的回复:]
怎样将sql数据库字段中的NULL都替换为空。给个sql语句把


update record set land_user=''where land_user= null我试了这样的都不对啊
[/Quote]

NULL 是不能用比较符号的,可以
update record set land_user=''where land_user IS null

OR
update record set land_user=''where ISNULL(land_user,'') = ''
勿勿 2011-08-26
  • 打赏
  • 举报
回复 1
select isnull(lang_user,'') as lang_user form record

or

update record where lang_user is null
叶子 2011-08-26
  • 打赏
  • 举报
回复
--判断null用is不是=

--如果不更新,在取数据的时候用
select isnull(land_user,'') as land_user from record
--也是可以的
chuanzhang5687 2011-08-26
  • 打赏
  • 举报
回复
update record set land_user=''where land_user is null
--小F-- 2011-08-26
  • 打赏
  • 举报
回复
update record set land_user=''where land_user is null
飘零一叶 2011-08-26
  • 打赏
  • 举报
回复
update record set land_user=''where land_user is null

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧