Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Windza
Yak Posting Veteran
61 Posts |
Posted - 2008-10-23 : 02:40:42
|
| Hi all - I'm looking for an easy way for basic 'copy/paste' type statement to overwrite one table with another from a different database within the same SQL instance... I'm assuming this can be done relatively easily? |
|
|
Windza
Yak Posting Veteran
61 Posts |
Posted - 2008-10-23 : 02:56:02
|
| Nevermind - this seemed to work...Delete table to replace... then run the following:SELECT * INTO [DB1].[dbo].[table1] FROM [DB2].[dbo].[table2] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-23 : 02:57:25
|
| due you mean overwrite data? if yes just do belowTRUNCATE TABLE desttableINSERT INTO desttableSELECT * FROm srctablewhere srctable is table copied from databse and desttable your final table.Alternatively you could use export-import wizard to copy all data from other db table to your table. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-23 : 04:23:31
|
quote: Originally posted by Windza Nevermind - this seemed to work...Delete table to replace... then run the following:SELECT * INTO [DB1].[dbo].[table1] FROM [DB2].[dbo].[table2]
Truncate table [DB1].[dbo].[table1] INSERT INTO [DB1].[dbo].[table1] SELECT * FROM [DB2].[dbo].[table2]MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|