x

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                    

more ▼

asked Jan 31, 2010 at 01:52 AM in Default

avatar image

Deepak Ghosh
12 2 2 2

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first
more ▼

answered Jan 31, 2010 at 03:15 AM

avatar image

Squirrel 1
1.6k 1 3 5

(comments are locked)
10|1200 characters needed characters left

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

more ▼

answered Jan 31, 2010 at 07:24 AM

avatar image

Kristen ♦
2.2k 7 11 14

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2018
x455
x39

asked: Jan 31, 2010 at 01:52 AM

Seen: 2515 times

Last Updated: Jan 31, 2010 at 03:09 PM

Copyright 2016 Redgate Software. Privacy Policy