newtoperlpgm
asked on
SQL Server Query automated and output to csv
In SQL Server 2008 I need to do the following and am new to SQL Server. I've been searching the web to see the best solution.
1) query table
2) output results to .csv file with two header lines, not just one
3) perform weekly
4) make automated
Thank you for your help.
1) query table
2) output results to .csv file with two header lines, not just one
3) perform weekly
4) make automated
Thank you for your help.
ASKER
Yes I have all the tools I need to connect to the database. The solution to which you referred uploads the csv file into a table, but I need to do the opposite, I need to download the data from the database into a csv file.
Thanks.
Thanks.
ASKER
I may have misunderstood, I think you were only referring to the bulk copy (below) step from the solution you referenced.
job step
xp_cmdshell 'bcp a.dbo.lang out c:\mssql\mailcsv.csv -n -T'
Thank you.
job step
xp_cmdshell 'bcp a.dbo.lang out c:\mssql\mailcsv.csv -n -T'
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Let me work backwards to help get you started.
I am assuming you have a SQL 2008 machine available to you and it has the SQL Agent configured and running. The SQL Agent will be the tool to achieve item 3 and 4 in your question.
SQL Agent can be found generally your SSMS (SQL Server Management Studio). This is the GUI frontend to administer the SQL Environment.
The next thing to do is use the SQL Agent to create a new SQL Job.
This job will be used to accomplish item 1 and 2 in your question.
Here is a great solution already on EE that gives you an example of the code needed in the SQL Agent job...
https://www.experts-exchange.com/questions/27913009/need-help-with-best-way-to-create-the-csv-file-and-the-nightly-process.html
See how you go...
T