question

Deepak Ghosh avatar image
Deepak Ghosh asked

How to pass a CSV to a stored procedure for an IN statement

                    
declare @Table1 table (RegNo int, RegName varchar(10))                    
insert into @Table1                    
select 55,'James'                    
union select 56,'Frank'                    

Now i need to fetch records through Stored Procedure like following

                    
CREATE PROCEDURE [dbo].[Sp_FindNo]                    
@RegNo int                    
As                    
Select RegName from Table1 where RegNo in (@RegNo)                    
GO                    

Now the problem is like if i do the following then an error displays

                    
EXEC Sp_FindNo '55,56'                    
or                     
EXEC Sp_FindNo 55,56                    
sql-server-2005stored-procedurescsv
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Squirrel 1 avatar image
Squirrel 1 answered
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kristen avatar image
Kristen answered

If you were using SQL 2008 you could pass a Table to a Stored Procedure

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.