ダッチオーブンの底

好奇心旺盛でいろんなことにチャレンジするが、ことごとく失敗ばかりする文系未経験プログラマーが体験して、皆さんの役に立ちそうな情報を発信していくブログです。

【ANSI_NULLS】の使い方 SQL Server

sql server でnull値同士で比較したい場合
ANSI_NULLS
null値の比較をするとときにこれがoffだとtrue
onだとfasleが変える

SET ANSI_NULLS ON
DECLARE @test AS INT
declare @test2 as int
set @test = NULL
set @test2 = NULL
declare @isnull as nvarchar(max)
declare @isnotnull as nvarchar(max)
set @isnull = 'null許容'
set @isnotnull = 'null非許容'

if @test = @test2
begin 
select @isnotnull
end
else 
begin 
select @isnull
end