try this Declare @sqlString nvarchar(4000)
SET @sqlString = "Select * from #ExtReturn order by'"+ @sort+"'" exec @sqlString That is how run any dynamic query that I need to create and it works great. Zach Bowling Sr. Manager of Customer Analytics Email: [EMAIL PROTECTED] http://www.direct-alliance.com -----Original Message----- From: Teel, C. Doug [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 28, 2002 3:24 PM To: SQL Subject: Stored Procedure Variable Help I'm trying to pass in a variable like @sort and select out of a temp table and order by that variable. I can't get this to work no matter what combination of quotes and concationations I use. Any help is greaty appreciated. I'm lost. @sort varchar(50) SET @sort = 'lname' --bunch of joins and selects here dumped into #extreturn -- my last attempt exec ("Select * from #ExtReturn order by'"+ @sort+"'") this works fine: exec ("Select * from #ExtReturn order by Lname) Thanks, Doug ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
