为什么不将nvarchar变量设置为null在此存储过程中不返回任何内容?

Xai*_*oft 4 sql t-sql sql-server

当@RadioServiceGroup设置为NULL时,我想返回sbi_l_radioservicecodes表中包含大约120条记录的所有记录.但是,当我执行以下过程并将@RadioServiceGroup设置为NULL时,它不返回任何记录.这是存储过程:

CREATE PROCEDURE [dbo].[GetRadioServiceCodes] 
@RadioServiceGroup nvarchar(1000) = NULL
AS
BEGIN
IF(@RadioServiceGroup = NULL)
    BEGIN
        SELECT rsc.RadioService
        FROM sbi_l_radioservicecodes rsc    
    END
    ELSE
    BEGIN       
        SELECT rsc.RadioService
        FROM sbi_l_radioservicecodes rsc
        WHERE rsc.RadioServiceGroup = @RadioServiceGroup    
    END
END
Run Code Online (Sandbox Code Playgroud)

Cor*_*ger 13

尝试"IS NULL"而不是"= NULL"

  • 我不知道为什么会这样.我才知道,因为我已经获得了白痴认证. (2认同)