不好意思,我对sql一窍不通,现在需要将字段gf(允许空)内容复制到字段lp(不允许空)中,实际中字段gf有些是空的,输入(update l_goods2 set lp=gf)提示“无法将 NULL 值插入列~~~该列不允许空值。UPDATE 失败”,求解

解决方案 »

  1.   

    如果是空的你希望用什么来填充?update l_goods2 set lp=isnull(gf,'设置一个为空时的值')
      

  2.   

    不好意思,字段gf是varchar类型,字段lp提示是numeric类型(实际软件中字段gf我们填的是数值)
      

  3.   

    update l_goods2 set lp=isnull(gf,'0')
    为空时用0填充吧
      

  4.   

    还是有问题诶,“将数据类型 varchar 转换为 numeric 时出错。”,楼上求助
      

  5.   

    select isnull(convert(numeric(10,2),IS_MEMBER('dasdasdsadsa')),'0')
      

  6.   

    select * from  l_goods2 where isnumeric(gf)=0看看是否存在不是数字的字符
      

  7.   

    晕 函数错了、是这个
    select isnull(convert(numeric(10,2),isnumeric ('dasdasdsadsa')),'0')
      

  8.   

    update l_goods2 set lp=cast(isnull(gf,0) as numeric(10,2))
      

  9.   

    update l_goods2 set lp=isnull(gf,'')