将数据从服务器上的SQL数据库导入到localhost上的SQL数据库

时间:2022-11-04 16:03:53

We have a database with a very large amount of data in it (around 400k records per table). I'd like to be able to debug a stored procedure on this database, however I do not have the permissions to do that on the server it's on.

我们有一个数据库,其中包含大量数据(每个表约有40万条记录)。我希望能够在此数据库上调试存储过程,但是我没有权限在它所在的服务器上执行此操作。

As such, I need to create a replica of the database on localhost and debug from there.

因此,我需要在localhost上创建数据库的副本并从那里进行调试。

However.. due to the large size the script that gets created is too large for SQL Server Management Studio to open.

但是..由于大尺寸,创建的脚本太大而无法打开SQL Server Management Studio。

Is there a way to directly import the data from one database to another if one is located on localhost and the other is not? The security issues shouldn't be a problem for importing/exporting data, I'm told.

有没有办法直接将数据从一个数据库导入另一个数据库,如果一个数据库位于localhost而另一个数据库不是?我被告知,安全问题不应该是导入/导出数据的问题。

2 个解决方案

#1


2  

Just create a binary backup of the source database (e.g. using SQL Server Management Studio, right click on the database, then select Tasks -> Back Up), then import that .bak file into your local installation - again using Management Studio, right click on the "Databases" node and choose Restore Database.

只需创建源数据库的二进制备份(例如,使用SQL Server Management Studio,右键单击数据库,然后选择任务 - >备份),然后将.bak文件导入本地安装 - 再次使用Management Studio,右键单击在“数据库”节点上,选择“还原数据库”。

The only thing that might prevent you from doing that is if you are running SQL Server Express locally and the total size of the source database exceeds the size limit of the Express edition.

唯一可能阻止您这样做的是,如果您在本地运行SQL Server Express,并且源数据库的总大小超过了Express版本的大小限制。

#2


2  

If you can connect to the server database from your computer, you can use SQL Server Management Studio, right click the Database, menu option Tasks and then Copy Database. You'll see an easy wizard asking for source and destination databases.

如果可以从计算机连接到服务器数据库,则可以使用SQL Server Management Studio,右键单击“数据库”,“菜单”选项“任务”,然后单击“复制数据库”。您将看到一个简单的向导,询问源数据库和目标数据库。

You can also create a backup through SQL Server Management Studio and restore on your computer.

您还可以通过SQL Server Management Studio创建备份并在计算机上还原。

#1


2  

Just create a binary backup of the source database (e.g. using SQL Server Management Studio, right click on the database, then select Tasks -> Back Up), then import that .bak file into your local installation - again using Management Studio, right click on the "Databases" node and choose Restore Database.

只需创建源数据库的二进制备份(例如,使用SQL Server Management Studio,右键单击数据库,然后选择任务 - >备份),然后将.bak文件导入本地安装 - 再次使用Management Studio,右键单击在“数据库”节点上,选择“还原数据库”。

The only thing that might prevent you from doing that is if you are running SQL Server Express locally and the total size of the source database exceeds the size limit of the Express edition.

唯一可能阻止您这样做的是,如果您在本地运行SQL Server Express,并且源数据库的总大小超过了Express版本的大小限制。

#2


2  

If you can connect to the server database from your computer, you can use SQL Server Management Studio, right click the Database, menu option Tasks and then Copy Database. You'll see an easy wizard asking for source and destination databases.

如果可以从计算机连接到服务器数据库,则可以使用SQL Server Management Studio,右键单击“数据库”,“菜单”选项“任务”,然后单击“复制数据库”。您将看到一个简单的向导,询问源数据库和目标数据库。

You can also create a backup through SQL Server Management Studio and restore on your computer.

您还可以通过SQL Server Management Studio创建备份并在计算机上还原。