dbTalk Databases Forums  

Export Single line before query into .txt

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Export Single line before query into .txt in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jeff
 
Posts: n/a

Default Export Single line before query into .txt - 01-26-2004 , 02:34 PM






Hi

I'm trying to export a file from a query into a .txt
file. This is a 150 character fixed width file.

That part works fine but the file is being sent to a bank
and they need the first row to be a string of characters
that have nothing to do with the data being pulled from
the query.

For example my normal output file is like:

A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

The bank needs a header row that looks like:

ASNN23443*JFHUHS333000212

So I have to create an output file that looks like:

ASNN23443*JFHUHS333000212
A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

I can create one or the other but I can not create the
header and then have the rest of the data "appended" into
the file. Each time anything is output to the file it
deletes the entire file and starts over.

Anyone have any idea how to either insert a header row
into a .txt file or append data to a file without
deleteing the header?

Any help is greatly appreciated.

Using SQL 2000

Thanks

Jeff

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Export Single line before query into .txt - 01-26-2004 , 02:55 PM






In message <4d6001c3e44b$baaaed30$a601280a (AT) phx (DOT) gbl>, Jeff
<anonymous (AT) discussions (DOT) microsoft.com> writes
<snip>
Quote:
For example my normal output file is like:

A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

The bank needs a header row that looks like:

ASNN23443*JFHUHS333000212

So I have to create an output file that looks like:

ASNN23443*JFHUHS333000212
A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

I can create one or the other but I can not create the
header and then have the rest of the data "appended" into
the file. Each time anything is output to the file it
deletes the entire file and starts over.

snip

Jeff,

There is no way to do this directly in DTS. A simple workaround is to
create two files and then append one to the other, either through some
script that reads the two files, or my favourite method is just to use
DOS copy-

copy file1.txt+file2.txt newfile.txt

Another similar method is to DOS type-

type file2.txt > file1.txt


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #3  
Old   
Jason Callas
 
Posts: n/a

Default Re: Export Single line before query into .txt - 02-20-2004 , 10:40 AM



You can use Multiphase portion of a data pump. This breaks the data pump
into 6 different phases. One of the phases is call Pre Source Data which
gets called once at the beginning of the transformation. You can use this
phase to write out a header to the output file.

- Jason

"Jeff" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi

I'm trying to export a file from a query into a .txt
file. This is a 150 character fixed width file.

That part works fine but the file is being sent to a bank
and they need the first row to be a string of characters
that have nothing to do with the data being pulled from
the query.

For example my normal output file is like:

A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

The bank needs a header row that looks like:

ASNN23443*JFHUHS333000212

So I have to create an output file that looks like:

ASNN23443*JFHUHS333000212
A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

I can create one or the other but I can not create the
header and then have the rest of the data "appended" into
the file. Each time anything is output to the file it
deletes the entire file and starts over.

Anyone have any idea how to either insert a header row
into a .txt file or append data to a file without
deleteing the header?

Any help is greatly appreciated.

Using SQL 2000

Thanks

Jeff



Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: Export Single line before query into .txt - 02-26-2004 , 06:58 AM



Do you have an example of how you would do this?

Cheers
Darren

"Jason Callas" <JayCallas (AT) hotmail (DOT) com> wrote

Quote:
You can use Multiphase portion of a data pump. This breaks the data pump
into 6 different phases. One of the phases is call Pre Source Data which
gets called once at the beginning of the transformation. You can use this
phase to write out a header to the output file.

- Jason

"Jeff" <anonymous (AT) discussions (DOT) microsoft.com> wrote in message
news:4d6001c3e44b$baaaed30$a601280a (AT) phx (DOT) gbl...
Hi

I'm trying to export a file from a query into a .txt
file. This is a 150 character fixed width file.

That part works fine but the file is being sent to a bank
and they need the first row to be a string of characters
that have nothing to do with the data being pulled from
the query.

For example my normal output file is like:

A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

The bank needs a header row that looks like:

ASNN23443*JFHUHS333000212

So I have to create an output file that looks like:

ASNN23443*JFHUHS333000212
A THISISANEAAMPLE JOE SMITH TEST
B ANOTHER EXAMPLE GEORGEWILL TEST

I can create one or the other but I can not create the
header and then have the rest of the data "appended" into
the file. Each time anything is output to the file it
deletes the entire file and starts over.

Anyone have any idea how to either insert a header row
into a .txt file or append data to a file without
deleteing the header?

Any help is greatly appreciated.

Using SQL 2000

Thanks

Jeff





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.