c. doug,
this works (disclaimer: but i'm no stored procedure expert so
there's probably a better way):
use pubs
go
create proc test
as
declare @sqlstring varchar(8000),@sort varchar(50)
set @sort = 'lname'
set @sqlstring = 'select * from employee order by '+@sort+' '
exec(@sqlstring)
go
~ dina
----- Original Message -----
From: "Teel, C. Doug" <[EMAIL PROTECTED]>
To: "SQL" <[EMAIL PROTECTED]>
Sent: Tuesday, May 28, 2002 5:24 PM
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
>
>
>
>
>
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists