title: How do I save the html output of a query to a text file, using a variable?
body: <p>I have a query that is more complicated, but basically creates an HTML page for me.  </p>
  
  <pre><code>DECLARE @indSubject varchar(7)
  SET @indSubject = '61-0036'
  
  --  LOTS of query stuff here that makes a page.  For simplicity 
  --  just use this:
  
  SELECT '&lt;html&gt;&lt;body&gt;' + @indSubject + '&lt;/body&gt;&lt;/html&gt;'
  </code></pre>
  
  <p>I want to do two things:</p>
  
  <ol>
  <li>Have SQL Server save this on my machine somewhere with the name of
  @indSubject.html (e.g. C:\TEMP\HTMLOUTPUT\61-0036.html)</li>
  <li>Be able to pass different values to the @indSubject (e.g. 91-0003). 
  Something command line-ish ?</li>
  </ol>
  
  <p>Can I do this with BCP?  Some other way ?</p>
  
  <p>Please note, this is all my personal stuff and this is not being deployed on a web server so I don't have to really worry to much about security, SQL Injection etc (at least I hope I don't!)</p>