sqlcmd

How to use SQL Server command sqlcmd to run a Transact-SQL script file

Developers should use sqlcmd to connect to a named instance of Microsoft SQL Server first and after they can run Transact-SQL script file.  A Transact-SQL script file is a text file that can contain a combination of Transact-SQL statements, sqlcmd commands, and scripting variables.  To run the script file, developers should follow the next steps:

1. Open …

Learn more

How to use SQL Server command sqlcmd to save output to a text file

Developers can run a Transact-SQL script file, by saving its output to a text file. In this case, developers should follow the next steps:

1. Open a command prompt window.

2. In the Command Prompt window, type:

sqlcmd -S server\instance -i C:\script.sql –o C:\result.txt

Where server is SQL server name, instance is SQL instance …

Learn more