Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL
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
Comments
joshrduncan2012 at 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 at 28-Nov-12 14:44pm
   
What result you are getting now?
Mathlab at 28-Nov-12 17:27pm
   
have you ever heard of a subquery?
Madhuri Patil at 29-Nov-12 2:31am
   
Hey ,guys I have solved this problem.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

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
  Permalink  
Comments
Madhuri Patil at 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 at 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 at 29-Nov-12 14:18pm
   
And...
Madhuri Patil at 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 at 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)

  Print Answers RSS
0 CPallini 325
1 Sergey Alexandrovich Kryukov 249
2 OriginalGriff 230
3 George Jonsson 130
4 ChauhanAjay 104
0 OriginalGriff 6,464
1 Sergey Alexandrovich Kryukov 5,915
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100