We help IT Professionals succeed at work.

Moving data from one SQL database to another

3can
3can asked
on
182 Views
Last Modified: 2010-03-19
I need to move data from one SQL database to another, I am using SQL Server 2005 but dont know much about it. I can run scripts if someone provides with the code. My knowledge so far has allowed me to setup a new database, run a script to create the tables and set security for the db, and thats Im afraid.

An "SQL for dummies" type explanation would be very much appreciated.




Comment
Watch Question

AneeshDatabase Consultant
CERTIFIED EXPERT
Top Expert 2009

Commented:
Option1 : using "Copy database wizard"
Right click on the database ->Tasks ->Copy database wizard
Now you just need to enter the user credentials and the SQL server instance to which you need to attach this db.
Jai STech Arch

Commented:
open management studio(SSMS)
--> select the database --> right click --> Export
the export wizard will be opened...
click next
select the source database (from which you want to export your data)
next
select the destination database(to where you want to export)
select the tables you want to export...
complete the wizard...
you data are transfered.
AneeshDatabase Consultant
CERTIFIED EXPERT
Top Expert 2009

Commented:
Make a copy of a database using BACKUP and RESTORE
This example uses both the BACKUP and RESTORE statements to make a copy of the Northwind database. The MOVE statement causes the data and log file to be restored to the specified locations. The RESTORE FILELISTONLY statement is used to determine the number and names of the files in the database being restored. The new copy of the database is named TestDB. For more information, see RESTORE FILELISTONLY.

Step1.

BACKUP DATABASE Northwind
   TO DISK = 'c:\Northwind.bak'  

Step2.
--now copy that Backupfile and paste at the target machine


Step3.
RESTORE FILELISTONLY
   FROM DISK = 'c:\Northwind.bak'
-- When you run the above statement, it will give ou the logical names, make a note of those names

Step4.
RESTORE DATABASE TestDB
   FROM DISK = 'c:\Northwind.bak'
   WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf',      --- 'Northwind' is the logical name of the MDF file
   MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'            -- 'Northwind_Log' is the logical name of the LDF file

Author

Commented:
Sorry forgot mention I am using:

SQL Server management studio express.

I also only need to copy certian categories from one database.
AneeshDatabase Consultant
CERTIFIED EXPERT
Top Expert 2009

Commented:
oops , i thought you want 2 move the entire db , In case you just need to move few tables, you must follow the instructions "JaiGanesh" mentioned.
Jai STech Arch

Commented:
open management studio(SSMS)
--> select the database --> right click --> Export
the export wizard will be opened...
click next
select the source database (from which you want to export your data)
next
select the destination database(to where you want to export)
select the tables you want to export...
complete the wizard...
you data are transfered.

:-)))

Author

Commented:
JaiGanesh

Dont know if I am being dumb but when I right on the db I only get the following options:
New Database
New Query
Script Database
Tasks
Rename
Delete
Refresh
Properties

When browsing help I found the following command:

bcp Utility

bcp AdventureWorks.Sales.Currency out "Currency Types.dat"

Does this sound like a command I could ?

??


Jai STech Arch

Commented:
under tasks --> you have EXPORT DATA
(i must have been more clear)

Author

Commented:
From Taksk it goes:

detach
shrink
restore
backup
generate scripts
Tech Arch
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.