Getting error while running 50 MB script on SQL Server 2008 R2

Deadly 提交于 2019-11-29 20:25:28

use the command-line tool SQLCMD which is much leaner on memory. It is as simple as:

SQLCMD -d <database-name> -i filename.sql

You need valid credentials to access your SQL Server instance or even to access a database

Chris Schiffhauer

Adding to @user1293068's answer, I needed to specify the instance name. Here is my full syntax:

sqlcmd -S <ComputerName>\<InstanceName> -d <DatabaseName> -i <MyScript.sql>

This is documented on Technet's Use the sqlcmd Utility article.

(Note that you must enter a switch value of "-S", not "-s". The switch is case-sensitive.)

If credentials are required

sqlcmd -S <ComputerName>\<InstanceName> -U <username> -P <password> -d <DatabaseName> -i <MyScript.sql>
dstetsenko

You can also try increasing the Maximum Server Memory value in server properties.
To edit this setting, right click on server name and select Properties > Memory tab.

I encountered this error trying to execute a 30MB SQL script in SSMS 2012.
After increasing the value from 1024MB to 2048MB I was able to run the script.

CarneyCode

Ok, none of the answers were sufficient to get my script successfully restoring.

So:

  1. Ensure that your network account has sufficient permissions to access both SQL Server instance and the specific database you intend to restore.

  2. It's best that the database you intend to restore actually exists, if it was merely generated from Generate Scripts (with modifications to include both Schema and Data)

  3. Run the command-line tool in Administrator mode (if necessary), e.g., type CMD from Run on the start menu

  4. In the command-line tool, type something like "SQLCMD -d CMS -i C:\Carnotaurus\Data\script.sql". Here, CMS is the name of the database I intend to restore and "C:\Carnotaurus\Data\script.sql" is the full file path of the restore script that was generated by the Generate Scripts in SMSS.

I hope this clears-up a few missing steps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!