Link to home
Start Free TrialLog in
Avatar of MarketingDrive
MarketingDrive

asked on

Copy SQL Table from 1 database to another

I added another database to my SQL 2005 server and need to copy some table from the old database, what is the easiest method to do so.   By the way, I use MS SQL Server management Studio to manage the tavles, views etc.
ASKER CERTIFIED SOLUTION
Avatar of Truzenzex
Truzenzex
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes, you can export and import wizard but if you wish to do it by T-SQL than here is the command.


select * into db2..table1 from db1..table1 where db1..table1.id>50
or

insert into db2..table1
select * from db1..table1 where db1..table1.id>50
Right-Click on the source database in SQL Management Studio and choose 'Tasks' and then Export Data. This will bring up a wizard that will guide you..
Avatar of FatEric13
FatEric13

Hi MarketingDrive,

I did the following to copy an existing table in our production db to our test db (on the same sql server, but in different databases):

In your Microsoft SQL server Management Studio, open a 'new query' window.

Past following in the window and edit the names between [ ]
USE [targetDBname];SELECT * INTO [targetTable] FROM [sourceDB].dbo.[sourceTable]

Hope this helps you.