pen*_*ake 4 t-sql null expression
如果字段不为NULL,则返回TRUE的正确语法是什么?如果TSQL中为NULL,则返回FALSE?
SELECT -- here return TRUE if table.Code IS NOT NULL. And FALSE otherwise
FROM table
Run Code Online (Sandbox Code Playgroud)
在mssql中没有真或假.您可以使用数据类型位,并将1视为true,将0视为false:
SELECT CASE WHEN Code IS NULL THEN CAST(0 AS BIT) ELSE CAST(1 AS BIT) END as Result
FROM table
Run Code Online (Sandbox Code Playgroud)
select case
when code IS NULL then 'false'
else 'true'
end as result
from the_table
Run Code Online (Sandbox Code Playgroud)