在sqlServer存儲過程中,聲明一個變量,但是沒有賦值的情況下,其值默認爲NULL
測試代碼:
create PROCEDURE [dbo].[test]
AS
BEGIN
declare @testValue int
print '聲明@testValue 並不賦值'
if(@testValue IS NULL)
print '@testValue is null'
else
print '@testValue is not null'
--設置爲0
print '賦值@testValue =0'
set @testValue =0
if(@testValue IS NULL)
print '@testValue is null'
else
print '@testValue is not null'
END
執行及結果: