Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Inserting data into a table from openquery w/ Var

Author  Topic 

dtanis
Starting Member

14 Posts

Posted - 2004-07-20 : 08:21:48
I have following statement retrieving a data set from an openquery. As you can see, I am also passing a variable.

How can I get this result set into a table? I have tried to place the "...into TABLE..." command in a couple different places, all without success.

Code is below. Any help is welcome! Thank you.

---------------------------------------------------------
Drop Table Data

GO

Declare @Query VarChar(8000), @Start_Dte VarChar(20)

Set @Start_Dte = '17-JUL-2004 21:00:00'

Set @Query = 'Select * From OpenQuery (CDB,
''Select
*
From
CDB.WorkOrder
Where
Last_Change_Date_And_Time > To_Date(''''' + @Start_Dte + ''''',''''DD-MM-YYYY HH24:MI:SS'''') And RowNum < 10
'')'

Exec (@Query)
   

- Advertisement -