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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Can I use variable with OVER(ORDER BY) statement?

Author  Topic 

Tiendq
Starting Member

4 Posts

Posted - 2006-01-10 : 10:10:56
Hi,

Can I use variable instead of dynamic query with following statement, e.g. SELECT ROW_NUMBER() OVER(ORDER BY ' + @OrderByClause + ') AS RowNumber, column1, column2,... '

Thank you,

nr
SQLTeam MVY

12543 Posts

Posted - 2006-01-10 : 11:46:03
nope.
You can pass flags in though
order by case when @custidflg = 1 then custid else null end ,
case when dteflg = 1 then dte else null end


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -