Hi I have a select which works great where I use CHARINDEX on a varchar column, but when I try it on a integer column I get the following error;
Argument data type int is invalid for argument 1 of charindex function.
Below I have listed both queries.
stremail is varchar intEmployeeID in integer
**below returns results as aspected**
SELECT intEmployeeID
FROM [dbo].[tblEmployees]
WHERE CHARINDEX(',' + strEmail + ',', ',' + REPLACE('[email protected], [email protected]', ' ', '') + ',') > 0
**below I get an error if I'm trying to select on a integer column**
SELECT intEmployeeID
FROM [dbo].[tblEmployees]
WHERE CHARINDEX(',' + intEmployeeID + ',', ',' + REPLACE('1, 2', ' ', '') + ',') > 0
Any help would be most greatful.
SELECT intEmployeeID
FROM [dbo].[tblEmployees]
WHERE CHARINDEX(',' + cast(intEmployeeID as nvarchar(max)) + ',', ',' + REPLACE('1, 2', ' ', '') + ',') > 0