RE: Retrieve a value from Openquery

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Oscar F (OscarF_at_discussions.microsoft.com)
Date: 11/18/04


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.
>
>



Relevant Pages

  • Problem with CURSOR (and OPENQUERY against ORACLE)
    ... We only want to retrieve matching records, so we have to filter the data on the remote server. ... declare @Isin varchar ... Open ICursor ...
    (microsoft.public.sqlserver.programming)
  • Problem with CURSOR FETCH
    ... We only want to retrieve matching records, so we have to filter the data on the remote server. ... declare @Isin varchar ... Open ICursor ...
    (microsoft.public.sqlserver.programming)
  • Re: TimeZone Info from Windows Registry
    ... DECLARE @test varchar ... EXEC master..xp_regread ... > I have a situation where I need to retrieve the TimeZone ...
    (microsoft.public.sqlserver.programming)
  • Re: Retrieving SqlCommand parameter values
    ... > Trying to retrieve the value of the Sqlcommand' parameter as integer. ... > Here is how I declare it: ... if (paramId.Value is int) ...
    (microsoft.public.dotnet.languages.csharp)
  • Getting CD Track Info via the WMP Cdrom Object
    ... I'm using the wmp9 activex control in my custom application. ... things I need to do with my custom application is to resolve CD title and ... I use the Cdrom object to retrieve the playlist from a drive I usually track ...
    (microsoft.public.windowsmedia.sdk)