RIGHT(@test,2)结果不为null,是2个空格

解决方案 »

  1.   

    SqlServer里的NULL不是字符串为空格的意思.
      

  2.   

    DECLARE @test varchar(100)
    SET @test='x   '
    if charindex(' ',@test)>0
    set @test='xx'
    select @test
      

  3.   

    select right(@test,2)
    因为这个两个空格呀,GG
      

  4.   

    可以这样来处理:DECLARE @test varchar(100)
    SET @test='x   'SELECT case ltrim(rtrim(RIGHT(@test,2))) when '' then 'xx' when null then 'null' end