Execute sql query using windows terminal

less than 1 minute read

Problem Statement
I had a sql file which was almost 400MB. Whenever, I was going to excute that file using SQL managment studio, it shows the following error. By the way, I was using SQL Server 2019 Enterprise edition.

Solution

  • Use the command line tools which takes low memory. Command is as follows -
SQLCMD -d <database-name> -i filename.sql
  • Example:
PS D:\Backup\Scripts> SQLCMD -d AMBSConso -i testdb.sql