① 如何用sql语句将某一列数值中的空值替换为其它值
update 表名 set 字段名 = '你要的值' where 字段名 is null
② SQL怎么把一个值变成空值返回到界面
1是错误的语句。你可以在查询分析器了试一下。
2是对的。执行后a1列的值为字符串"null"而a2为null.
实际上你要插入某个字段为null,插入数据时不要该字段就可以了。例如
insert
into
s
(a1)
values
('null')
那么
a2的值就为null了。
③ sql如何把查询到的NULL替换成空值
1、这要看你如何保存你查询的结果。只能是你把你查询的结果保存为0,查询不会改变原本存在的值。表名test,字段a=.null.(int型),字段b=1,字段c=2 :select * from test into tabel test1
update set a=0 where a=.null。
2、用 IsNull(字段名, '') 可以将NULL的字段转换为空值,这在多个字段连接时很有用,因为NULL值+任何字段都是NULL。
3、将NULL替换为空create procere fill_null@tablename varchar(100) --表名asdeclare @colname varchar(100)declare col_cur cursor for select c.name from syscolumns c,sysobjects o where c.id=o.id and o.name=@tablename open col_curfetch next from col_cur into @colnamewhile @@fetch_status!=-1beginexec ('update '+@tablename+' set '+@colname+'='''' where '+@colname+' is null' )fetch next from col_cur into @colnam endclose col_curdeallocate col_cur
④ sql如何空值替换成null
各个数据库都有空值操作函数,例如Oracle的nvl,mysql的ifnull,sqlserver的isnull等
都可以把空值替换成另外一个内容,你这里只需要把空值替换“null字符”就可以了。
oracle:select nvl(字段,'NULL') from ****
mysql:select ifnull(字段,''NULL'') from ****
sqlserver,也类似,我就不写了
⑤ sql空值值转化为0
不知道你什么数据库。
如果是 Oracle
那么
NVL( (你那个子查询) , 0 ) AS 概念策划阶段
如果是 SQL Server
那么
ISNULL( (你那个子查询) , 0 ) AS 概念策划阶段
⑥ 如何用sql语句将某一列数值中的空值替换为其它值
UPDATE PRDT SET WH="0001" WHERE WH IS NULL
⑦ SQL空值替换成0的问题
你的数据类型是数值型,替换后将会将空字符值隐式转换为0
无论什么值,用isnull函数转换后都要根据原有值类型匹配
⑧ sql数据库如何把null转化为空字符
sqlserver中可用isnull函数:
selectisnull(null,'');
oracle中可用nvl函数:
selectnvl(null,'')fromal;
mysql中可用ifnull函数:
selectifnull(null,'');
⑨ 在sql server数据库中将一个nvarchar类型的空值转换成decimal(18,3)类型
select
case
when
charindex('g',isnull(DescFlexField_PrivateDescSeg3,''))=0
then
cast(0
as
decimal(18,3))
when
charindex('g',isnull(DescFlexField_PrivateDescSeg3,''))>0
then
cast(SUBSTRING(isnull(DescFlexField_PrivateDescSeg3,''),0,LEN(isnull(DescFlexField_PrivateDescSeg3,'')))
as
decimal(18,3))
else
cast(DescFlexField_PrivateDescSeg3
as
decimal(18,3))
end
from
sm_so
,每个字段都进行一次类型转换