RE: Retrieve a value from Openquery
From: Oscar F (OscarF_at_discussions.microsoft.com)
Date: 11/18/04
- Next message: Jon Jahren: "Re: SQL Server and SP2"
- Previous message: Z: "Re: SQL Server and SP2"
- In reply to: Rand Boyd [MSFT]: "RE: Retrieve a value from Openquery"
- Next in thread: Rand Boyd [MSFT]: "RE: Retrieve a value from Openquery"
- Reply: Rand Boyd [MSFT]: "RE: Retrieve a value from Openquery"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 18 Nov 2004 01:03:01 -0800
I see that this is a good way to have temporary table with an unic name. But
...
How can I retrieve the value stored in the temporary table and store it in a
local varible of my stored procedure?
The sample code of the article is:
-----------------------------------------------------------------------
-- Create the temporary table
execute ('create table '+ @mytable + '(col1 int)' )
-- Insert two rows in the table
execute ('insert into ' + @mytable + ' values(1)')
execute ('insert into ' + @mytable + ' values(2)')
-- Select from the temporary table
execute ('select col1 from ' + @mytable )
-----------------------------------------------------------------------
/****************************************
If I declare a variable here which sentence must I use to retrieve the value?
***************************************/
declare @myvariable varchar(200)
set @myvariable = execute ('select col1 from ' + @mytable ) -- I think that
something like this does not work.
Óscar.
"Rand Boyd [MSFT]" wrote:
> Article 175850 has a method to create a temporary table with a dynamically
> created name that may resolve the table exists error.
>
>
> Rand
> This posting is provided "as is" with no warranties and confers no rights.
>
>
- Next message: Jon Jahren: "Re: SQL Server and SP2"
- Previous message: Z: "Re: SQL Server and SP2"
- In reply to: Rand Boyd [MSFT]: "RE: Retrieve a value from Openquery"
- Next in thread: Rand Boyd [MSFT]: "RE: Retrieve a value from Openquery"
- Reply: Rand Boyd [MSFT]: "RE: Retrieve a value from Openquery"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|