title: schedule export SQL query to csv with custom name
body: <p>I was able to write a SQL query on a SQL Server 2008 database to show the data I need. Now I need to figure out how to export the query into a csv file automatically every night with the date of the export as the file name.</p>
  
  <p>My research tells me there are two ways to do it. One is using task scheduler to run a query file, or to use the server agent. Unfortunately I'm not able to get to agent working so I'll have to figure out how to write a query that will do what I need. </p>