Please Help Me
-
Hi to all, I want to write storedprocedure which take Name or Year as Parameter and Display Records Order by Name or Year. Note:From UI User may select Orderby Name or Year. Mkanchha
We can't write this for you because we don't know what your database schema is. If this is the only two orders you may want, I'd write a proc for each, otherwise I believe you need to build your SQL as a string and execute it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi to all, I want to write storedprocedure which take Name or Year as Parameter and Display Records Order by Name or Year. Note:From UI User may select Orderby Name or Year. Mkanchha
Pass "1" or "2" to the database and using simple if statement sort accordingly.
Regards, Arun Kumar.A
-
Hi to all, I want to write storedprocedure which take Name or Year as Parameter and Display Records Order by Name or Year. Note:From UI User may select Orderby Name or Year. Mkanchha
Or try this: select * from tblName order by case WHEN @parmaeter=1 then Name else Year end ASC
Regards, Arun Kumar.A
-
Or try this: select * from tblName order by case WHEN @parmaeter=1 then Name else Year end ASC
Regards, Arun Kumar.A
Thanks for your Replay. I get the SP it's comple successfully but while execute it giving the error. THIS IS MY sp ----------------- ALTER proc Test (@iOrder char(1)) as select * from tblabc order by case WHEN @iOrder='1' then vsName else nYOP end ASC -------------- EXEC TEST '1' -------------------- Error: Msg 8114, Level 16, State 5, Procedure Test, Line 4 Error converting data type varchar to numeric. ------------------------------------------------------ Please Tellme where I made Mistake Mkanchha
-
Thanks for your Replay. I get the SP it's comple successfully but while execute it giving the error. THIS IS MY sp ----------------- ALTER proc Test (@iOrder char(1)) as select * from tblabc order by case WHEN @iOrder='1' then vsName else nYOP end ASC -------------- EXEC TEST '1' -------------------- Error: Msg 8114, Level 16, State 5, Procedure Test, Line 4 Error converting data type varchar to numeric. ------------------------------------------------------ Please Tellme where I made Mistake Mkanchha
-