When @RadioServiceGroup is set to NULL, I want to return all the records from the sbi_l_radioservicecodes table which has about 120 records. However, when I execute the following procedure and set the @RadioServiceGroup to NULL, it returns no records. Here is the stored proc:
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
Try ‘IS NULL’ instead of ‘= NULL’