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

Truncating text files to a certain number of lines Expand / Collapse
Author
Message
Posted Monday, July 14, 2008 5:19 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 28, 2014 11:03 AM
Points: 247, Visits: 692
I've created a text log file in a package to hold execution results, but it's growing in size at an alarming rate. I need to be able to refer to the info in the file, so I don't want to stop it exporting the results to the file, however I would like to limit the number of lines it's exporting at present. As time goes on the earlier logged entries are of less importance to me so I think I can truncate the length of the log file. However I'm not sure what the best method is to delete the first x number of lines from the text file apart from importing in to a sql table and and using a select top command to write out the lines. Seems a bit over the top that though. Any ideas please?
Post #533405
Posted Monday, July 14, 2008 6:30 AM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Today @ 5:34 PM
Points: 36,793, Visits: 31,250
Instead of writing to a text file, why not write to a table where each row has a "create date"?

--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 #533438
Posted Monday, July 14, 2008 7:38 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 28, 2014 11:03 AM
Points: 247, Visits: 692
Is there no way of doing what I'm trying to do with text files though?
Post #533500
Posted Monday, July 14, 2008 7:57 AM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Today @ 5:34 PM
Points: 36,793, Visits: 31,250
You mean withing T-SQL? Sure... import the file... delete the desired rows... export the file. You could also write some VBS using the System File Object to do it for you and use xp_CmdShell to execute it.

--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 #533523
Posted Monday, July 14, 2008 8:01 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, July 28, 2014 11:03 AM
Points: 247, Visits: 692
OK then, so a workaround within SSIS rather than a function of SSIS it sounds. Thanks for your assistance here Jeff.
Post #533529
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse