• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

Exporting a SQL Server DB

Hi

I have a db in SQLServer Express 2005.  I simply need to export this in its entirety (data and structure) so that it can be imported into another instance of SQL Server Express 2005.  What is the best way of doing this?
0
kenabbott
Asked:
kenabbott
  • 5
  • 2
1 Solution
 
sm394Commented:
deattach db
copy to new location
and
attach db
0
 
ErnariashCommented:
Hello,
Back-Up / Restore
Detach / Attach
0
 
sm394Commented:
Pic for example
db.GIF
0
Independent Software Vendors: 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!

 
sm394Commented:
if you couldn't detach or copy  try taking database offline first
0
 
kenabbottAuthor Commented:
Thanks - but if you detach the db aren't you in effect moving it from one place to another.  What if you want to keep the db where it is and simply move a copy to the second location.

Also in mySQL I'ce used 'Dump SQL File' and then 'Execute batch file' to copy db's from one place to another - is there an equivalent in SQL Server??
0
 
ErnariashCommented:

As on the sm394 picture is an option to Copy Database is a wizard you will have options on it.
The problem with Detach / Attach you take your db ofline. For online copy you can use backup and restore  (with move if need it)

BACKUP DATABASE YourDB 
   TO DISK = 'c:\YourDB.bak'
RESTORE FILELISTONLY 
   FROM DISK = 'c:\YourDB.bak'
RESTORE DATABASE YourDB3 
   FROM DISK = 'c:\YourDB.bak'
   WITH MOVE 'YourDB_Data' TO 'c:\YourDB3.mdf' 

Open in new window

0
 
sm394Commented:
as Ernariash explained there are number of different options to do this task
with detach and taking database offline

you  copy the database .mdf files in to new location and attach them again
after copying mdf files you can bring db online again
0
 
sm394Commented:
the steps involved  for this
1-Take database offline
2-go to C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
  or the directory you have installed sql server
3- copy yourdb.mdf and youdb.ldf files
4- paste in new location
5- final step is right click properties attach browse for mdf ldf files
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now