Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Daily CSV Expand / Collapse
Author
Message
Posted Friday, May 16, 2014 2:21 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 4:00 PM
Points: 96, Visits: 252
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
Post #1571909
Posted Friday, May 16, 2014 2:36 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 6:55 AM
Points: 1,952, Visits: 5,081
What about SSIS?
Post #1571917
Posted Friday, May 16, 2014 3:40 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 8:54 PM
Points: 3,637, Visits: 7,932
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.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1571940
Posted Friday, May 16, 2014 4:12 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 4:00 PM
Points: 96, Visits: 252
Thanks for the feedback, I will look into it.

Jeff
Post #1571947
Posted Saturday, May 17, 2014 6:51 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 12:03 AM
Points: 37,065, Visits: 31,628
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1571990
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse