Quantcast
Channel: 簡睿隨筆
Viewing all articles
Browse latest Browse all 941

SQL null 的判斷

$
0
0

老生常談...

撰寫SQL Server Transact-SQL時,注意與null的判斷寫法,必須用 is nullis not null, 不可使用 `=' 或 '!='。

測試SQL:

declare @a varchar(2)
if @a is null
  print 'null'
else
  print 'in else'

▼ 變數@a是null,用 = 判斷時不會成立
gh|400

is null 才會成立
gh|500

##

您可能也會有興趣的類似文章


Viewing all articles
Browse latest Browse all 941

Trending Articles