开发者

case null SQL Server 2008

开发者 https://www.devze.com 2023-02-01 07:45 出处:网络
How t开发者_运维百科o check for null in case statement in SQL Server 2008CASE WHEN column IS NULL THEN 1 ELSE 0 END

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

精彩评论

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