How can I backup a remote SQL Server database to a local drive?

前端 未结 23 1292
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 16:20

I need to copy a database from a remote server to a local one. I tried to use SQL Server Management Studio, but it only backs up to a drive on the remote server.

Som

相关标签:
23条回答
  • 2020-11-30 17:06

    You can try SQLBackupAndFTP. It will create scripts to create all the objects in your database and INSERT statements for all the rows in your tables. In any database you can run this script file and the entire database will be re-created.

    0 讨论(0)
  • 2020-11-30 17:06

    I know this is an older post, but for what it's worth, I've found that the "simplest" solution is to just right-click on the database, and select "Tasks" -> "Export Data-tier Application". It's possible that this option is only available because the server is hosted on Azure (from what I remember working with Azure in the past, the .bacpac format was quite common there).

    Once that's done, you can right-click on your local server "Databases" list, and use the "Import Data-tier Application" to get the data to your local machine using the .bacpac file.

    Just bear in mind the export could take a long time. Took roughly two hours for mine to finish exporting. Import part is much faster, though.

    0 讨论(0)
  • 2020-11-30 17:06

    If you use the Generate Scripts under SSMS, click the Advanced button. Under the 'Generate Scripts for the dependent objects' option, click True. By clicking that any dependencies of each object will also be scripted out in proper order.

    0 讨论(0)
  • 2020-11-30 17:09

    If you are on a local network you can share a folder on your local machine and use it as destination folder for the backup.

    Example:

    • Local folder:

      C:\MySharedFolder -> URL: \\MyMachine\MySharedFolder

    • Remote SQL Server:

      Select your database -> Tasks -> Back Up -> Destination -> Add -> Apply '\\MyMachine\MySharedFolder'

    0 讨论(0)
  • 2020-11-30 17:11

    First, grant full control permissions to a local path on your machine (as shown below) with Everyone. (Or alternatively grant permissions specifically to the SQL Server Agent account).

    Second, execute the following:

    BACKUP DATABASE [dev] TO  DISK = N'\\myMachine\c\dev.bak' WITH COPY_ONLY, INIT;
    
    0 讨论(0)
  • 2020-11-30 17:13

    To copy data and schema only (will not copy stored procedures, functions etc.), use the SQL Server Import and Export Wizard, and choose New... when choosing the destination database.

    Right Click Database > Tasks > Import Data.

    Choose a Data Source

    • Data Source: SQL Server Native Client
    • Server Name: the remote server
    • Authentication:
    • Database: the db name

    Choose a Destination

    • Data Source: SQL Server Native Client
    • Server Name: the local server
    • Authentication:
    • Database: New...

    The rest is straight forward.

    0 讨论(0)
提交回复
热议问题