12,552,952 members (55,266 online)
Rate this:
See more:
hello all,

I have pass comma separated parametor to Stored procedure but i don't get result,

E.g.
`@status_code='1','2';`

and I have replace it in SP like

`tof.case_status in(convert(varchar(max),@status_code))`

but i don't get result,

please tell me where i am wrong
Posted 28-Nov-12 2:27am
joshrduncan2012 28-Nov-12 9:02am

What result are you getting and what should you be getting? Can we see more of your code to get an idea of the context of how this is implemented? We can't assume anything based on what you have shown us already.
Maksud Saifullah Pulak 28-Nov-12 14:44pm

What result you are getting now?
Mathlab 28-Nov-12 17:27pm

have you ever heard of a subquery?

Hey ,guys I have solved this problem.

Rate this:

## Solution 1

Basic information, you'll find here: http://msdn.microsoft.com/en-us/library/ms177682.aspx[^]

Below, example code should works:
```CREATE TABLE #tof(case_status INT)

INSERT INTO #tof(case_status)
VALUES (1)
INSERT INTO #tof(case_status)
VALUES (2)
INSERT INTO #tof(case_status)
VALUES (3)
INSERT INTO #tof(case_status)
VALUES (4)
INSERT INTO #tof(case_status)
VALUES (5)

DECLARE @status_code NVARCHAR(300)
DECLARE @sql_query NVARCHAR(300)

SET @status_code='1, 2'
SET @sql_query = 'SELECT * ' +
'FROM #tof ' +
'WHERE case_status IN (' + @status_code + ')'
EXEC (@sql_query)

DROP TABLE #tof```

thanks buddy,
I have apply same as your solution only the littlebit difference,in mine and your solution.but thanks.

hi,
I have solve this problem for varchar,I have the problem in,
my parametor is varchar and DB type is Int so what i do in that case,
actually I have cast it but it throw conversion error.
Maciej Los 29-Nov-12 14:18pm

And...

And... what do you mean sir... I don't understand
I am telling you my problem,but anyway I have solved it.
thanks..
Maciej Los 30-Nov-12 12:43pm

Thank you ;)

Top Experts
Last 24hrsThis month
 OriginalGriff 125 Suvendu Shekhar Giri 95 ppolymorphe 60 Jochen Arndt 50 F-ES Sitecore 50
 OriginalGriff 3,991 Suvendu Shekhar Giri 1,898 John Simmons / outlaw programmer 1,687 ppolymorphe 1,631 Karthik Bangalore 1,210