Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
saran_d28
Starting Member
36 Posts |
Posted - 2009-10-28 : 09:18:01
|
| Hi,My table have 23 Columns. I want to retrive only 9 columns from the table based on the input parameters of the Stored Procedure.For ExampleTable(T1) have 3 columns(c1, c2, c3) and the datas are look like.c1 c2 c31 A 01-jan-2009 2 B 02-jan-20093 C 03-jan-2009and stored procedure have 3 input parameters ( p1, p2, p3)My requirement is 1) if the user pass the parameter p1 as "All", then i want all the rows . else match the p1 into column c1 and retrive particular rows only( For ex if the user pass p1 as 1, then output is 1 row only)2) if the user pass the parameter p2 as "All", then i want all the rows . else match the p2 into column c2 and retrive particular rows only( For ex if the user pass p2 as a, then output is 1 row only)3) if the user pass the parameter p3 as "All", then i want all the rows . else match the p3 into column c3 and retrive particular rows only( For ex if the user pass p3 as 01-jan-2009, then output is 1 row only)How to achieve this, without dynamic SQL.And my stored procedure is CREATE PROCEDURE TESTP(@P1 CHAR) AS BEGIN SELECT C1, C2, C3 FROM TEST WHERE C2 = (CASE WHEN @P1='ALL' THEN C2 ELSE @P1 END)This procedure take too much time for running.Please guide me to solve this issue. |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-10-28 : 09:28:36
|
| Search DEFAULT Argument in BOLSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
|
|
|
|
|