Sunday, February 19, 2012

Export to .txt file using SQL Server DTS

I am exporting a SQL Server 2000 table to an "errors.txt" file. I can get this to work just fine. I need to be able to plug the date and record count into my file name...(ex. MMYYYYCCCCerrors.txt).

The first 6 characters are the month and year of the file. CCCC represents a record count with leading zeroes.

Current Process - An ASP page has an "Export" button on it. After the "Export" button is clicked, a Stored Proc is called and the SP executes the DTS package. The DTS package just copies the data from a table to a .txt file.

Thanks.Hello Len,

I would propose that you add an ActiveXTask to your DTS-package, which manipulates the properties of your export task.

This ActiveXskript defines a variable with your desired file name (e.g. MMYYYYCCCCerrors.txt) and checks if this files exists in OS level. If it does exist, increase CCCC by 1 and check again.

For better help on this topic look at this article (http://www.sqldts.com/default.aspx?235). Generally, this site offers me quite a lot of help.

Hope this helps you! Otherwise post a reply.

Greetings,
Carsten

No comments:

Post a Comment