SQL Server Copying tables from one database to another -
i have 2 databases, 1 called natalie_playground
, 1 called livedb
. since want practice insert, update things, want copy of tables livedb
natalie_playground
.
the tables want copy called: customers, computers, cellphones, prices
what tried (using ssms) right click on table there no copy in there!
assuming have 2 databases, example , b:
if target table not exists, following script create (i not recommend way):
select table_a.field_1, table_a.field_2,......, table_a.field_n copy_table_here a.dbo.table_from_a table_a
if target table exists, then:
insert table_target select table_a.field_1, table_a.field_2,......, table_a.field_n a.dbo.table_from_a table_a
note: if want learn , practice this, can use previous scripts, if want copy complete structure , data database another, should use, "backup , restore database" or, "generate script database data" , run database.
Comments
Post a Comment