13,145,302 members (68,365 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?
Madhuri Patil 29-Nov-12 2:31am

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```
Madhuri Patil 29-Nov-12 2:33am

thanks buddy,
I have apply same as your solution only the littlebit difference,in mine and your solution.but thanks.
Madhuri Patil 29-Nov-12 4:01am

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...
Madhuri Patil 30-Nov-12 0:42am

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 ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 440 Dave Kreskowiak 205 Richard Deeming 195 Richard MacCutchan 110 RickZeeland 100
 OriginalGriff 5,650 Graeme_Grant 5,051 ppolymorphe 1,884 Jochen Arndt 1,834 CPallini 1,625

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 28 Nov 2012