It's not going to work because local temporary table is local in scope and will be dropped at the end of sp_executesql, EXECUTE or any stored procedure it created in.
>
>The only way you might be able to do this is via a dynamic SQL statement. (see sp_executesql in the BOL). That's about as close to VFP macro substitution as you can get in SQL. Something like this:
>
>
>DECLARE @cMyTempTable VarChar(25)
>SET @cMyTempTable = [unique string]
>
>DECLARE @String NVARCHAR(1000)
>set @String = N!'SELECT * INTO #' + @cMyTempTable +
>'FROM dbo.MySourceTable'
>
>sp_executesql @string
>
>
>I didn't test this so the usual disclaimers apply.
>
>However - and this is a big warning - local temporary tables only exists as long as the session that creates them is alive. So, if you pass this temp table output parameter to, say, a client application, and sever the connection, you're hosed.
--sb--