I have stored procedured called GetReport
customers.branches_ID is int type
however @Branches parameter is varchar
@Branches is "10,13534,554,776,767"
I want to search 10,13534,554,776,767 in branches_ID however if i cast/convert to varchar it is not working for me.
ALTER PROCEDURE [dbo].[GetReport]
@fromDate datetime,
@toDate datetime,
@Branches varchar (500) = null
AS
BEGIN
SET NOCOUNT ON;
select * from customers where
(customers.CreatedDate between @fromDate and @toDate) and
(@Branches is null or CONVERT(varchar(500), customers.branches_ID) in(@Branches )) -- This part is not working for me
END
how can i solve this problem how can i search multiple comma varcvhar inside of int column ?
Thanks.