Watch this example on YouTube
1. here is my stored procedure
ALTER PROCEDURE spPassStrings
@SelectedNames Varchar(max)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @SQL Varchar(max)
Set @Sql = 'SELECT * FROM Customers WHERE FisrtName IN (' + @SelectedNames + ')'
Exec (@SQL)
END
GO
2. and here is how to call it
Declare @FNames Varchar(Max) = '''Mark'', ''Frank'''
Exec spPassStrings @FNames
What if we have two variables. One same as above and the other one with single value.
ReplyDelete