Dec 20, 2000 #1 jrdatla Programmer Dec 19, 2000 7 US Can we Use a parameter in the Order by clause of SELECT Statment in the Declarative statment of a Cursor. If so, can you give a small example Jr. Datla
Can we Use a parameter in the Order by clause of SELECT Statment in the Declarative statment of a Cursor. If so, can you give a small example Jr. Datla
Dec 21, 2000 #2 TomSark MIS Oct 19, 2000 448 US The only way to do this would be to dynamically build a sql string and EXECute it as in: USE PUBS GO DECLARE @mycol sysname, @sqlstr varchar(1000) SET @mycol = 'au_lname' SET @sqlstr = 'SELECT * FROM authors ORDER BY ' + @mycol EXECUTE (@sqlstr) Tom Davis tdavis@sark.com http://www.sarkdallas.com Upvote 0 Downvote
The only way to do this would be to dynamically build a sql string and EXECute it as in: USE PUBS GO DECLARE @mycol sysname, @sqlstr varchar(1000) SET @mycol = 'au_lname' SET @sqlstr = 'SELECT * FROM authors ORDER BY ' + @mycol EXECUTE (@sqlstr) Tom Davis tdavis@sark.com http://www.sarkdallas.com