Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to add an EOF marker to a Tab delimted text file being exported from SQL using DTS

Posted on 2008-10-08
8
Medium Priority
?
476 Views
Last Modified: 2013-11-30
I am VERY new to SQL and DTS.  I have created a SQL statement that selects the data I need and I have figured out how to use the DTS Export wizard to create a tab delimited file.  However, I need to add an EOF marker to the end of the destination text file.  I also need to name the destinatiion file dynamically based on the date.  Can you help me with some very detailed instructions on how to do this?

Thanks, DixieBP
0
Comment
Question by:dixiebp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 22675584
>>However, I need to add an EOF marker to the end of the destination text file. <<
Any reason why? And if so define EOF in ASCII

>>I also need to name the destinatiion file dynamically based on the date. <<
See here:
How can I change the filename for a text file connection?
http://www.sqldts.com/200.aspx
0
 

Author Comment

by:dixiebp
ID: 22677813
Thank you.....the file naming now works.  Do you know of a way too add an EOF marker after the last line of data in the text file?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 22683558
>>Do you know of a way too add an EOF marker after the last line of data in the text file?<<
Again, any reason you have to do that?  An EOF character is very rarely needed and has not been needed since mid-80's. If you still want to do it, than you will have to define what you mean by EOF in ASCII.  CHAR(26) perhaps?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:dixiebp
ID: 22687036
We are sending the file to a company that uploads it into their system.  They require some type of EOF marker to they know they have received a complete file.  It can literally be the text "EOF" after the last line of data in the file.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 200 total points
ID: 22691861
Than you will have a couple of options:
1. Open the file using the FileSystemObject and write it out, when you get to the end write out "EOF".
2. Change your query that exports the data to a UNION query and add SELECT "EOF" at the end.  This second option is simpler, but may be dependent on the number of columns and column delimiter.
0
 
LVL 51

Assisted Solution

by:Mark Wills
Mark Wills earned 200 total points
ID: 22694101
Or even at the end of your export, run a command or batch that simply does a copy / concatenate

at the dos prompt, try this :

1) as a one time process, create an EOF file:
echo EOF > eof.txt

2) then as a normal part of your process, run a command / batch to:

copy myexportedtable.txt+eof.txt newexportedfilewitheof.txt

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question