The environment is sql 2008 R2.
I have attached a sql query that works fine to output the data I need. The thing I would like to do is automate the script as much as possible as I will have to change c1alias and c2alias of the where statement out everytime I run the script. Is there way to have the output saved as a csv file directly to a folder in the structure called c:\bbfolders\filename.csv.
The actual filename will be a combination of the values c1alias and c2alias that are used for the query. The filename would be c1alias.c2alias.csv. Can I even do what I want to do? And if I can output it to a csv file is there a way to declare c1alias and c2 alias in the beginning so that I only have to enter these values onces each time I run the script?
I would be really nice if I could populate c1alias and c2alias from a text file or csv file and have each line run as a query and output the data as a seperate csv file, but that may be asking to much. I have about 400 of these combinations that I need to run so anything that can make this faster is greatly appreciated.
c1alias as 'client number',
c2alias as 'matter number',
c_alias as 'doc type',
t_alias as 'app type',
dateadd(HH,-6,editwhen) as 'Last Edit Date'
ORDER BY docnum, version asc