September 11, 2007 at 3:25 pm
Hi,
I'm new to SQL and I need to create a SP to copy the contents of a TABLE and dump it to a csv or txt file.
If the csv file is already there, then the data in my Table must be added and not overwritten.
Does anyone has a sample of this functionality ?
Thanks in advance
September 12, 2007 at 5:10 am
How do you know that the data is already in the existing file? Are you going to read this file back in and check for existence? Unless this is an XML file, I don't think you could read it in from a sproc and iterate through the rows. In this case you'd need to create an SSIS package with a Script Component to handle the file iteration.
Alternative:
Create a temp table which resembles the data you want to dump to a file. Your query would then read this temp table and either INSERT, or UPDATE the rows (SQL 2008 has a better way for doing this MERGE). Once you're done updating the temp table, you would then just dump this table to the "flat", or "deliminted" file, overwriting the file each night. Again for this process, I probably would create an SSIS package.
September 12, 2007 at 9:22 am
Please do not double post:
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=324&messageid=397907
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply