Sunday 25 March 2012

pass array of items in sql server stored procedure and fetch record from it.

First of all,u need to pass a string from ur .net app. like '1,2,3,4,5,6,7' or in any format.
Then use this function to split your comma seprated string and here is the stored procedure to fetch record.



CREATE procedure [dbo].[test](@parameter varchar(5000)) As
begin
declare @val varchar(max);
select * from emp where convert(varchar,Id) in(select * from dbo.fnSplit(@parameter,'.') )

end

No comments:

Post a Comment