Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing comma-separated value from .NET to stored procedure using the value in "IN" SQL function

I have an SQL query similar to the following:

create procedure test
(
   @param1 nvarchar(max)
)
as
begin
    select * from table where column1 in (@param1)
end

Now I need to pass the value of @param1 from my .net application in such a way that the above query works.

Can some one please advise me on how to pass from my VB.NET code a value which is similiar to below:

'1','2','3'

My main question is how do I structure value of parameter like above example from my .NET application?

like image 735
Amit Avatar asked Nov 18 '10 13:11

Amit


1 Answers

quickly like that, I would create a table valued function that would parse it so you can do

   select * 
   from table 
   where field in (select field from dbo.myfunction(@param1))
like image 51
Fredou Avatar answered Oct 03 '22 18:10

Fredou