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 name, script.sql is Transact-SQL script file and result.txt is file where output is stored.
3. Press ENTER