Run Transact-SQL Script Files Using sqlcmd–SQL Server T-SQL

Problem:

I recently received a script which creates a database and loads data.  I was unfortunately too large for SQL Server Management Studio to process.

Solution:

You can use the sqlcmd utility to run the script file. The example below shows the execution of a script file called script.sql which is located on the C drive and a connection is made to the SQL Server using integrated security.

To run the script file

  1. Open a windows command prompt window.
  2. In the command prompt window, type: sqlcmd –S SQLServerName-i C:\DatabaseLoad.sql
  3. Press ENTER.
About Carlos Ferreira

Leave a Reply

%d bloggers like this: