IN
needs to be as follows:
... IN (@param1, @param2, ...)
So, you should do:
SELECT DISTINCT Details from tbData WHERE Name IN (@svt) AND Address=@ser
Update:
The alter procedure statement you provided in your question is syntactically incorrect. My answer provides the correct syntax for writing the statement and it compiles.
Reading your question over again, I see you have in fact have two issues. The first was a syntax error and the second passing in a comma delimited list in a single parameter.
The answer is you simply cannot provided a comma delimited list of values at runtime into a single string type parameter that is used in the IN (...)
clause. Now, on this second point, I would argue that this is not a good design/programming approach to the problem, but it can be done using dynamic SQL or parsing out each value from the string parameter, store them into a temp table then revise your query to join to that, or use a (or use a table valued function and store the parsed items there, where it can be queried from.
Below is the corrected syntax for your code, but it would not solve the second aspect of passing in a string containing a comma delimited list of values. That could be solved as I described above.
For the syntax error, first, you can create a dummy table to test your code. Note, a typical database table should have a primary key. This is strictly a dummy table to test the statement:
CREATE TABLE TbData(
Name nvarchar(255),
Details nvarchar(255),
Address nvarchar(255)
);
Then, you can create the initial stored procedure:
CREATE PROCEDURE Test
(
@ser nvarchar(255),
@svt nvarchar(255)
)
AS
BEGIN
SELECT DISTINCT Details FROM tbData WHERE Name IN (@ser) AND Address = @svt
END
And finally, execute the alter stored procedure statement you had asked about:
ALTER PROCEDURE Test
(
@ser nvarchar(255),
@svt nvarchar(255)
)
AS
BEGIN
SELECT DISTINCT Details FROM tbData WHERE Name IN (@ser) AND Address = @svt
END