DECLARE @test varchar(100)
SET @test=''
if charindex('',@test)>0
set @test='x'
上面的查询不显示‘x'
1. 什么原因?如何显示‘x'2 上面的@test是空字符串(里面没有空格),同’ ‘(有三个空格)是否相同?
SET @test=''
if charindex('',@test)>0
set @test='x'
上面的查询不显示‘x'
1. 什么原因?如何显示‘x'2 上面的@test是空字符串(里面没有空格),同’ ‘(有三个空格)是否相同?
DECLARE @test varchar(100)
SET @test=''
if charindex('',@test)>=0
set @test='x'
print @test2.
bu xiang tong
SET @test='x'select charindex('',@test)
-- the result is also 0
--I need that WHEN ''
--THEN 'x'
--ELSE 'xxx'
SET @test=''
if charindex('',@test)>0 ----charindex鏄釜鍒ゆ柇瀛楃鐨勫嚱鏁帮紝瀛楃閮芥病鏈夋€庝箞鍒ゆ柇锛?
set @test='x' ---娌¤繍琛岃繖鍙?
2銆傜┖鏍间笉绛変簬鏃犲€硷紒锛? NULL涓嶇瓑浜庘€?鈥
SET @test='x'select charindex('',@test)
结果0DECLARE @test varchar(100)
SET @test=''select charindex('',@test)
结果0
如何检测字符中的空字符串当只有''时候(当中没有空格)时候显示‘x'
其他显示’y'(包括‘ ’也显示‘y')
SET @test=''
IF @test=''
select 1结果 1DECLARE @test varchar(100)
SET @test=' '
IF @test=''
select 1
结果 1
SET @test=''
IF @test=''
select 1结果 1DECLARE @test varchar(100)
SET @test=' '
IF @test=''
select 1
结果 1
那么上面的例子如何,使它根据‘’,和‘ ’
返回不同的结果?