SQL Server Runs Large SQL Files

Scenario Description

When running SQL files to import data into the SQL Server database, for small SQL files, simply open and execute them in SQL Server Management Studio. However, there are several tables with very large amounts of data, and when running SQL files, there is a prompt of insufficient memory.

Reference solution

Use the built-in sqlcmd command tool to perform imports.

1. If I am using sqlserver2008, which is installed on the d drive, open the command line and enter the Binn directory:

cd D:Program FilesMicrosoft SQL Server100ToolsBinn

2. Enter the following command.

sqlcmd -S localhost -U sa -P sasa -d chrysler -i e:sqluser_folder.sql

Explanation:

  1. -S: Database server address, I am using localhost directly on my local machine
  2. -U: username
  3. -P: Password
  4. -d: Database name
  5. -i: SQL file