开发者

what is the output of this code?

I have wriiten a part of code for you and I want to know the output ,I need your help because there is not any body for helping me also I think that the out put is A ,is this correct? thanks.

declare @v1 varchar(20),@v2 varchar(20)
select @v1 = 'NULL'
if @v1 is null and @v2 is null
select开发者_JAVA技巧 'A'
else
select 'B'

EDITED: also what is the value of @ v2 ? thanks


Why don't you try it yourself?

The output will be B because @v1 is assigned a string 'NULL' which is not the same as the special NULL meaning "no value"


In MSSQL 2008 it returns B. That is because @v1 is the string 'NULL', and not actually null. If you change it to

select @v1 = null

Then it will return A


I'd say it's B because = NULL and = 'NULL' are two different things.


@v2 is null, since you do not assing any value to it. The output is B ´cause NULL is not the same as the string 'NULL'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜