SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Daily CSV


Daily CSV

Author
Message
jayoub
jayoub
SSC-Addicted
SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)

Group: General Forum Members
Points: 451 Visits: 540
I have been assigned a task to have a query, which a developer wrote, run against a database on a daily basis and have it generate a csv file to be placed on a network drive.

Another tech suggested I use the xp_cmdshell to do this, but when I tried on a test server it said that the extended properties are not enabled.

We are running SQL 2008 here

The senior DBA suggested that we use PowerShell to do the task, but my powershell skills are not that great.

Do you have any suggestions on how I can accomplish this job?

Your help is appreciated

Jeff
Eirikur Eiriksson
Eirikur Eiriksson
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15702 Visits: 18626
What about SSIS?
Cool
Luis Cazares
Luis Cazares
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17120 Visits: 19122
I would go with SSIS as well, but if you want to do it with Powershell, there are plenty of examples in the web.
A search on google for "powershell export sql server csv" gave several posts.
Here are some examples.
http://poshcode.org/1662
http://www.sqlteam.com/article/fast-csv-import-in-powershell-to-sql-server
http://beyondrelational.com/modules/2/blogs/908/posts/18005/exporting-from-sql-server-to-csv-file-using-powershell.aspx


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
jayoub
jayoub
SSC-Addicted
SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)SSC-Addicted (451 reputation)

Group: General Forum Members
Points: 451 Visits: 540
Thanks for the feedback, I will look into it.

Jeff
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89573 Visits: 41144
jayoub (5/16/2014)
I have been assigned a task to have a query, which a developer wrote, run against a database on a daily basis and have it generate a csv file to be placed on a network drive.

Another tech suggested I use the xp_cmdshell to do this, but when I tried on a test server it said that the extended properties are not enabled.

We are running SQL 2008 here

The senior DBA suggested that we use PowerShell to do the task, but my powershell skills are not that great.

Do you have any suggestions on how I can accomplish this job?

Your help is appreciated


What does the file have to look like? For example, should column headers be included?

What about the data? For example, is there any possibility that the data might include a comma in it? If so, is a TAB delimited file an option?

Last but not least, what is the end use of the data? Is it for imports to something like Excel or is it a file that will be transmitted to somewhere else?

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search