老生常談...

撰寫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,用 = 判斷時不會成立

An image to describe post

is null 才會成立

An image to describe post

##