Importing large SQL file with SQL Server

Recently i came across a situation where i was not allowed to access the SQL Server database directly. This is quite troublesome since i have to move 3 big databases from the original server to another server in a different network segment, disconnected from each other.

Therefore, i cannot do the usual attach/detach, and maybe doing the backup/restore. Thus, i was left with using the SQL Server Management Studio (SSMS).

After exporting the database using the Generate Scripts menu, i was presented with a very big SQL file and i was unable to open it with SSMS because of its size. So i had to use this tool called sqlcmd which comes preinstalled with SQL Server. sqlcmd is a command line tool to run scripts file, TSQL statements, and system procedures.

The basic syntax for sqlcmd is :

sqlcmd -S servername -U username -P password -d database_name -V 17 -i filename.sql

This is a sample usage :

sqlcmd -S "Beast" -U "sa" -P "sa123" -d testDB -V 17 -i testdb.sql

-V stands for error_severity_level, which i’m still unable to understand what it’s supposed to do. Tinkered with it for a while, but nothing happened.

Oh well, I guess the more you know, the more you don’t know.

 

Leave a comment