Click to See Complete Forum and Search --> : Copy SQL Server table


anita
October 15th, 2001, 01:31 PM
I have two SQL Server databases with the same table. One of the tables gets updated by the user. How can I copy the updated table to the table in the other database when a user clicks on a VB cmd button "update table".

Thanks for your help.

Iouri
October 15th, 2001, 02:57 PM
Execute the following SQL

sSQL = "insert into db2.dbo.table2 select * from db1.dbo.table1"
conn.Execute sSQL

Iouri Boutchkine
iouri@hotsheet.com

anita
October 15th, 2001, 04:19 PM
Iouri,

Will this code append to the existing rows or replace all the rows? I need to replace all existing rows. Essentially, I want to re-create the table.

Thanks!

Cimperiali
October 16th, 2001, 03:29 AM
Re-create? Then you can drop all from first table, and after that insert form the second.

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Iouri
October 16th, 2001, 08:42 AM
It will append rows. As Cimperiali said you can delete records from the table and then append.

Iouri Boutchkine
iouri@hotsheet.com

Iouri
October 16th, 2001, 08:42 AM
It will append rows. As Cimperiali said you can delete records from the table and then append.

Iouri Boutchkine
iouri@hotsheet.com

Iouri
October 16th, 2001, 08:42 AM
It will append rows. As Cimperiali said you can delete records from the table and then append.

Iouri Boutchkine
iouri@hotsheet.com