我的代码是@td nvarchar(50) 
if @TD='' set @TD=null
我在调试时,输入''(两个单引号),可是if @TD=''仍判断为假如何才能判断为真?

解决方案 »

  1.   

    @td nvarchar(50) 
    set @id = ''
    if @TD='' set @TD=null 
      

  2.   

    if @td is null 
    set @td=null
      

  3.   

    set @td=case when len(isnull(@td,''))=0 then null else @dt end
      

  4.   


    if @TD='' set @TD=null
    这样已经是正确的吧, 
      

  5.   

    declare @td nvarchar(50) 
    set @td =''
    if @td ='' set @TD=null select @td
      

  6.   

    --貌似判断结果就是为真的吧?
    declare @td nvarchar(50) 
    set @td = ''
    if @TD='' set @TD=null select @TD结果:NULL
      

  7.   

    没赋初始值就不正确.declare @td nvarchar(50) if @TD='' 
       print '@td 为空'
    else
       print '@td 不为空'
    /*
    @td 不为空
    */
    declare @td nvarchar(50) 
    set @td = ''
    if @TD='' 
       print '@td 为空'
    else
       print '@td 不为空'
    /*
    @td 为空*/
      

  8.   

    我是从vb中向存储过程中的参数@TD传值的,vb中我输入的是""
      

  9.   

    可是在执行if @TD='' set @TD=null ,仍不能得到set @TD=null 的结果
      

  10.   

    试试
    if len(rtrim(ltrim(@TD)))=0 set @TD=null或者
    if @td is null set @TD=null
      

  11.   

    vb中nothing表示空,‘’就不是了
      

  12.   


     @td nvarchar(50) 
    if len(@TD)=0
       print '@td 为空'
    else
       print '@td 不为空'
      

  13.   

    @td nvarchar(50) 
    set @id = '' 
    if @TD='' set @TD=null