 <p>You can do this using scripting variable and using the <code>-v</code> option of <code>SQLCMD</code> utility. A small example from <a href="http://msdn.microsoft.com/en-us/library/ms188714.aspx" rel="nofollow"> MSDN Documentation</a></p> <p>Consider that the script file name is <code>testscript.sql</code>, <code>Col1</code> is a scripting variable; your SQL script look like</p> <pre><code>USE test; SELECT x.$(Col1) FROM Student x WHERE marks &lt; 5; </code></pre> <p>You can then specify the name of the column that you want returned by using the <code>-v</code> option like</p> <pre><code>sqlcmd -v Col1 = "FirstName" -i c:\testscript.sql </code></pre> <p>Which will resemble to below query</p> <pre><code>SELECT x.FirstName FROM Student x WHERE marks &lt; 5; </code></pre> <p><strong>EDIT:</strong></p> <p>If you just want to capture the output from your script file then you can use <code>-o</code> parameter and specify a outfile like</p> <pre><code>sqlcmd -v Col1 = "FirstName" -i c:\testscript.sql -o output.txt </code></pre>