Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Copy SQL Table from 1 database to another

Posted on 2009-04-29
5
Medium Priority
?
247 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:MarketingDrive
5 Comments
 
LVL 1

Accepted Solution

by:
Truzenzex earned 2000 total points
ID: 24259843
Easiest method would be to use the Import Data function, this will allow you to copy tables, views etc...
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24259916
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
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24259922
or

insert into db2..table1
select * from db1..table1 where db1..table1.id>50
0
 
LVL 25

Expert Comment

by:reb73
ID: 24260016
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..
0
 
LVL 1

Expert Comment

by:FatEric13
ID: 24260167
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question