Search This Blog

Google Analytics

Tuesday, April 02, 2013

MSSQL: Run Large SQL Script

Having problems when running large SQL scripts using the SQL Management Studio (SSMS)? I would suggest you use sqlcmd instead. Save your script in a flat file (e.g. .sql or .txt) and pass the file as an input parameter to sqlcmd like below.

sqlcmd -S SERVER\INSTANCE -i mysqlscript.sql

In case you are having problems logging in, you may wish to try either one of them.

sqlcmd -S SERVER\INSTANCE,PORT -i mysqlscript.sql

OR

sqlcmd -S np:\\127.0.0.1\pipe\MSSQL$INSTANCE\sql\query -i mysqlscript.sql

NOTE: Replace SERVER, INSTANCE, PORT accordingly to suit your server configuration.

Hope it helps.

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.

Popular Posts