开发者

case null SQL Server 2008

How t开发者_运维百科o check for null in case statement in SQL Server 2008


CASE WHEN column IS NULL THEN 1 ELSE 0 END


Sometime you need case isnull(column, 99) when 99 then "null" when 1 then ....


Using Case in Select Query:

Example:

SELECT UserID, UserName, CASE(UserAmendId) AS UID WHEN 0 THEN 'True' ELSE 'False' END 
FROM UserTable

It shows records with field UID=true where its Value=0, otherwise it show False where its Value is Null.

Table Name: UserTable
Columns: UserID (int), UserName (varchar(50)), UserAmendID (int)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜