copy a database within SQL Server Express?

前端 未结 13 2571
眼角桃花
眼角桃花 2020-12-07 22:02

I would like to make a copy of a database I have but keep it on the same server as a test database. However, everything I have found is to use the copy database wizard (I am

相关标签:
13条回答
  • 2020-12-07 22:56

    In SQL Server Express 2012 you can do following steps:

    1. Create a backup of the database you want to copy
    2. right-click "Databases" and select "Restore Files and Filegroups"
    3. Enter the name of the new database in the "To database" field.
    4. Select "From device" and then select the file that you backuped in the first step
    5. click "OK"

    this will "clone" the Database with the correct table settings such as the "default value" and "auto increase" etc.

    0 讨论(0)
  • 2020-12-07 22:59

    SQL Express database has an export button, I just exported the database to a new database on the same server, it is copying the database. Just right-click on the database name.

    0 讨论(0)
  • 2020-12-07 22:59

    I just thought of a really nifty way to get around this :) So I thought I should post my idea. Note that this is 'untested' but I think it will work.

    1. Do a "Back Up..." database (theoretically this is on your production server, but it doesn't have to be)
    2. Copy the backup file (from your prod server) onto your development machine
    3. Assuming you're using SSMS Developer Edition on your development machine, you can then do a "Restore" onto your development machine, then do a "Copy Database" afterwards also on your development machine (to create a new copy of the DB)
    4. Now do a "Back Up..." on the new DB you just created, copy the backup file (to your production server) and do a "Restore" on the sql server express server :)

    Hope this helps out a few people :)

    Cheers,

    Jeff

    0 讨论(0)
  • 2020-12-07 22:59

    I think you could try import data to a new database.

    1. Create an empty database in your local sql server
    2. Right click on the new database -> tasks -> import data
    3. In the SQL Server Import and Export Wizard, select product env's servername as data source. And select your new database as the destination data.
    0 讨论(0)
  • 2020-12-07 23:02

    I found the problem! Click on Databases, restore, then do the following: After choosing from where to restore, and writing destination db name, go to files [annotation 1 on picture] and change the very right column files names to different than original [annotation 2 on picture] then it works :)

    0 讨论(0)
  • 2020-12-07 23:04

    Try making a backup of your database, and restoring it into a brand new database.

    • Create new DB.
    • Make a full backup of your original.
    • Right click on your new DB, hit restore.
    • Navigate to your .BAK, and ensure the .mdf and .ldf match the new.
    0 讨论(0)
提交回复
热议问题