Exporting a SQL Server DB


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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Faizan SarwarSoftware / Database DeveloperCommented:
deattach db
copy to new location
attach db
Back-Up / Restore
Detach / Attach
Faizan SarwarSoftware / Database DeveloperCommented:
Pic for example
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Faizan SarwarSoftware / Database DeveloperCommented:
if you couldn't detach or copy  try taking database offline first
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??

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)

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

Open in new window

Faizan SarwarSoftware / Database DeveloperCommented:
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
Faizan SarwarSoftware / Database DeveloperCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.