January 29, 2004 at 3:44 am
How do you copy a table from one db to another in a store procedure. I must do this in runtime from a delphi application. That is why I want to do it in a store procedure.
I now you can have a cursor and loop throught it and as you loop through it you can insert into the other table. But are there a more efficient way to do it ?
Thank you
Karen
January 29, 2004 at 6:40 am
The simple solution for copying data is
to create the table and insert
SELECT *
INTO newdatabase..newtable
FROM olddatabase..oldtable
WHERE ...
to insert into an existing table
INSERT
INTO newdatabase..newtable
(col1,col2,col3...)
SELECT col1,col2,col3...
FROM olddatabase..oldtable
WHERE ...
But I'm thinking that you might want more than this such as primary key, indexes, procedures. Also are both database on the same server? Is the table name/contents dynamic?
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply