我有一个 sql server 表,其中包含一个名为 [type] 的 int 列,该列可以为空。我有以下将类型作为输入的存储过程:
@Jobtype VARCHAR(50) = '',
@Language INT
AS
BEGIN
SELECT [TabId]
,CASE
WHEN @Language = 2 THEN [TabNameTextLang2]
ELSE [TabNameTextLang1]
END AS TabName
,CASE
WHEN @Language = 2 THEN [PageTitleLang2]
ELSE [PageTitleLang1]
END AS PageTitle
,[TabLink]
,[Type]
,[Priority]
,[DutyStationId]
,[DateCreated]
,[DateModified]
,[Deleted]
FROM dbo.hr_Tabs
WHERE Deleted = 0 AND
((@Jobtype = '' and [Type] is null) or ([Type] = CASt(@Jobtype as int )))
END
该表有一行类型为空。我希望当我将 @jobtype 作为 '' 传递时,只选择该行,否则行按其类型显示。但是当我尝试传递上面的存储过程参数时
exec myproce '', 1
我得到所有记录
请在我的案例中建议如何根据类型过滤记录