blossompark
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?
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?
Yes you can do this as you are executing the query from your local server.
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
This will get the data into a local table in memory....how do i load "localTable into a database?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Kaminda, thanks for that,
running that query now,,,takes about 20 mins so will update you when finished
running that query now,,,takes about 20 mins so will update you when finished
ASKER
Hi kaminda, perfect...worked ...and so simple!!! thank you!!
Hi Mrugesh1...thanks for your contribution!!
Hi Mrugesh1...thanks for your contribution!!