Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Daily CSV


Daily CSV

Author
Message
jayoub
jayoub
SSC-Enthusiastic
SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)

Group: General Forum Members
Points: 167 Visits: 497
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
SSCertifiable
SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)

Group: General Forum Members
Points: 6809 Visits: 17748
What about SSIS?
Cool
Luis Cazares
Luis Cazares
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8566 Visits: 18143
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-Enthusiastic
SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)SSC-Enthusiastic (167 reputation)

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

Jeff
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45307 Visits: 39934
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

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