sql_language thread: Stroed Proc passing variable to order sql statement
Thanks Siva, That has worked great... I had a big query with lots of variables to create into a string which was fun but your solution worked fine. Cheers, Stephen > > Hi > You can try something like below. I tried and it works. > > CREATE PROCEDURE proc_Test > @orderbyfield nvarchar(250) > AS > > declare @sqlQuery nvarchar(250) > set @sqlQuery = 'Select Field1,Field2 from SampleTable order by' + > @orderbyfield + ' Asc ' > Exec(@sqlQuery) > > > Let me know if it solved your problem. > Siva. >
|





