I have an sql server table with an int column named [type] which is nullable. I have following stored procedure which gets type as input:
@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
this table has a row where type is null. I want that when i pass @jobtype as '' then only that row is selected otherwise rows are shown by their type. But when I try to pass above stored procedure parameters like
exec myproce '', 1
I get all records
Please suggest how to filter records based on type in my case
typeis 0?CAST('' as int)produces a 0, so the second part of the condition could be true.