Link to home
Start Free TrialLog in
Avatar of blossompark
blossomparkFlag for Ireland

asked on

Loading query results directly into a database in sql server 2005

I have fired a query against a linked server from SQL Server 2005.
I would like to load the results directly into  a local database table by creating the table dynamically, is this possible without first saving the results as a csv file and then loading into a pre created table in the local database?
Avatar of kaminda
kaminda
Flag of Sri Lanka image

Yes you can do this as you are executing the query from your local server.
Avatar of blossompark

ASKER

Hi Kaminada, thanks for your response,

I have fired the following query at a linked server which returns a complete table

SELECT  * FROM OPENQUERY(PROD,'
select *  from PEOPLE
 ')

But do I have to create a table in the target database before I can load the results of the query?
This table has about 50 columns so i am trying to avoid manually creating it, just hoping there is some sort of "smart" way to create a table on the fly if you understand me
SOLUTION
Avatar of Mrugesh1
Mrugesh1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Mrugesh1, thanks for your response.
This will get the data into a local table in memory....how do i load "localTable into a database?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Kaminda, thanks for that,
running that query now,,,takes about 20 mins so will update you when finished
Hi kaminda, perfect...worked ...and so simple!!! thank you!!


Hi Mrugesh1...thanks for your contribution!!