|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SQL code passed with a parameterHi everybody
My application calls a stored procedure that runs a select statement. The procedure accepts an input parameter (varchar) named @OrderBy. User chooses a sort order from a combo-box and the application supplies the order by clause to the stored procedure with the @OrderBy parameter. For example, the value of @OrderBy could be ' ORDER BY ColumnA, ColumnB, ColumnC DESC'. My question is how to use the value of the @OrderBy parameter inside my SELECT statement, as it obviously doesn't work like this: SELECT ... FROM ... WHERE ... ORDER BY @OrderBy Thanks Howard Hi
http://www.aspfaq.com/show.asp?id=2501 and http://www.sommarskog.se/dynamic_sql.html Regards -------------------------------- Mike Epprecht, Microsoft SQL Server MVP Zurich, Switzerland IM: m***@epprecht.net MVP Program: http://www.microsoft.com/mvp Blog: http://www.msmvps.com/epprecht/ Show quote "Howard" <How***@discussions.microsoft.com> wrote in message news:08F8FA2D-C32B-47BE-B0EA-231871E64333@microsoft.com... > Hi everybody > > My application calls a stored procedure that runs a select statement. The > procedure accepts an input parameter (varchar) named @OrderBy. User > chooses a > sort order from a combo-box and the application supplies the order by > clause > to the stored procedure with the @OrderBy parameter. > > For example, the value of @OrderBy could be ' ORDER BY ColumnA, ColumnB, > ColumnC DESC'. > > My question is how to use the value of the @OrderBy parameter inside my > SELECT statement, as it obviously doesn't work like this: > SELECT ... FROM ... WHERE ... ORDER BY @OrderBy > > Thanks > Howard > >
Other interesting topics
|
|||||||||||||||||||||||