title: TSQL - Trying to write printed output to a text file using batch file
body: <p>Im am currently using this command to try to write to a text file the output that I PRINTED in the sql console(messages) using a stored procedure that uses the 'print' command to print stuff. I want to get that printed stuff into a text file using bat executable.</p>
  
  <p>sqlcmd -Q "exec myprocedure" -S servername-d dbname-o C:\yourOutput.txt</p>
  
  <p>But whenever I run this batch file, it just opens the yourOutput.txt and its blank...</p>
  
  <p>C:\filepath\sqlcmd -Q "exec procedureName" -S servername-d dbname-o
  Sqlcmd: 'dbname-o': Unexpected argument. Enter '-?' for help.</p>