dbTalk Databases Forums  

Appending to a text file in Sql DTS

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


Discuss Appending to a text file in Sql DTS in the microsoft.public.sqlserver.dts forum.



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

Default Appending to a text file in Sql DTS - 03-29-2005 , 06:31 AM






Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran

Reply With Quote
  #2  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 03-29-2005 , 07:54 AM






There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
<Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Quote:
Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran


Reply With Quote
  #3  
Old   
Karunakaran
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-01-2005 , 12:01 AM



Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:

Quote:
There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran



Reply With Quote
  #4  
Old   
Karunakaran
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-01-2005 , 02:55 AM



Hi,

The DTS package works fine for the first time and subsequent runs when the
connection is not closed. When I close the Enterprise Manager and execute the
package again later everthing works fine till the batch process during the
batch process the files are not copied to one file. Any ideas what could be
the problem.

Thanks and Regards,
Karunakaran

"Karunakaran" wrote:

Quote:
Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:

There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran



Reply With Quote
  #5  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-03-2005 , 10:24 PM



Not really enough information to make a guess. What do you
mean by it runs when the connection is not closed?

-Sue

On Thu, 31 Mar 2005 23:55:03 -0800, "Karunakaran"
<Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Quote:
Hi,

The DTS package works fine for the first time and subsequent runs when the
connection is not closed. When I close the Enterprise Manager and execute the
package again later everthing works fine till the batch process during the
batch process the files are not copied to one file. Any ideas what could be
the problem.

Thanks and Regards,
Karunakaran

"Karunakaran" wrote:

Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:

There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran




Reply With Quote
  #6  
Old   
Karunakaran
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-04-2005 , 04:07 AM



Hello Sue,

When I mean the connection is not closed, I mean by not closing the
enterprise manager. Well now whether irrespective of whether I close the
enterprise manager or not still I could able to get this work. Sometimes the
batch does what its supposed to do sometimes the final file is still blank
nothing gets written to it.

Many posts says the easier way to achieve header and footer is to use
multiphase data pump but I dont find any code snippets which does it.

Any pointers towards it?

Thanks and Regards,
Karunakaran

"Sue Hoegemeier" wrote:

Quote:
Not really enough information to make a guess. What do you
mean by it runs when the connection is not closed?

-Sue

On Thu, 31 Mar 2005 23:55:03 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

The DTS package works fine for the first time and subsequent runs when the
connection is not closed. When I close the Enterprise Manager and execute the
package again later everthing works fine till the batch process during the
batch process the files are not copied to one file. Any ideas what could be
the problem.

Thanks and Regards,
Karunakaran

"Karunakaran" wrote:

Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:

There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran





Reply With Quote
  #7  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-04-2005 , 07:06 AM



Possibly how you are calling the batch file. The Win32
Process should be something like:
Win 32 Process: cmd.exe
Parameters: /c copy D:\Header.txt+D:\Data.txt
D:\FinalFile.txt
Enable the multiphase data pump, write the header in the Pre
Source Data phase. You can find some notes on it's usage at:
http://www.sqldts.com/default.aspx?t...&i=282&p=1&a=7

-Sue

On Mon, 4 Apr 2005 02:07:03 -0700, "Karunakaran"
<Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Quote:
Hello Sue,

When I mean the connection is not closed, I mean by not closing the
enterprise manager. Well now whether irrespective of whether I close the
enterprise manager or not still I could able to get this work. Sometimes the
batch does what its supposed to do sometimes the final file is still blank
nothing gets written to it.

Many posts says the easier way to achieve header and footer is to use
multiphase data pump but I dont find any code snippets which does it.

Any pointers towards it?

Thanks and Regards,
Karunakaran

"Sue Hoegemeier" wrote:

Not really enough information to make a guess. What do you
mean by it runs when the connection is not closed?

-Sue

On Thu, 31 Mar 2005 23:55:03 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

The DTS package works fine for the first time and subsequent runs when the
connection is not closed. When I close the Enterprise Manager and execute the
package again later everthing works fine till the batch process during the
batch process the files are not copied to one file. Any ideas what could be
the problem.

Thanks and Regards,
Karunakaran

"Karunakaran" wrote:

Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:

There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran






Reply With Quote
  #8  
Old   
Karunakaran
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-04-2005 , 11:51 PM



The batch file(sqlbatch.bat) has the following
copy/b D:\Header.txt+D:\Data.txt+ D:\FinalFile.txt

Win32 Process
I just call the batch file sqlbatch.bat

Other one from other forum suggested that I use the following
Type Header.txt>FinalFile.txt
Type Data.txt>>FinalFile.txt
Type Footer.txt>>FinalFile.txt

This seems to working..Atleast for now...Still I couldnt able to figure out
whats wrong with the batch file.

Thanks and Regards,
Karunakaran



"Sue Hoegemeier" wrote:

Quote:
Possibly how you are calling the batch file. The Win32
Process should be something like:
Win 32 Process: cmd.exe
Parameters: /c copy D:\Header.txt+D:\Data.txt
D:\FinalFile.txt
Enable the multiphase data pump, write the header in the Pre
Source Data phase. You can find some notes on it's usage at:
http://www.sqldts.com/default.aspx?t...&i=282&p=1&a=7

-Sue

On Mon, 4 Apr 2005 02:07:03 -0700, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hello Sue,

When I mean the connection is not closed, I mean by not closing the
enterprise manager. Well now whether irrespective of whether I close the
enterprise manager or not still I could able to get this work. Sometimes the
batch does what its supposed to do sometimes the final file is still blank
nothing gets written to it.

Many posts says the easier way to achieve header and footer is to use
multiphase data pump but I dont find any code snippets which does it.

Any pointers towards it?

Thanks and Regards,
Karunakaran

"Sue Hoegemeier" wrote:

Not really enough information to make a guess. What do you
mean by it runs when the connection is not closed?

-Sue

On Thu, 31 Mar 2005 23:55:03 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

The DTS package works fine for the first time and subsequent runs when the
connection is not closed. When I close the Enterprise Manager and execute the
package again later everthing works fine till the batch process during the
batch process the files are not copied to one file. Any ideas what could be
the problem.

Thanks and Regards,
Karunakaran

"Karunakaran" wrote:

Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:

There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:

Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran







Reply With Quote
  #9  
Old   
Simon Worth
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-05-2005 , 01:00 PM



Another problem you may encounter is when you exit and reopen EM, you
lose the path for the current working directory of the batch file, so
you need to specify where you want the batch file to copy from.
use the cd command to switch to the directory where your files are located.
IE -
REM Begginng of batch file
C:
cd Temp --You are now in the temp directory on your C: drive

Simon Worth

Karunakaran wrote:
Quote:
The batch file(sqlbatch.bat) has the following
copy/b D:\Header.txt+D:\Data.txt+ D:\FinalFile.txt

Win32 Process
I just call the batch file sqlbatch.bat

Other one from other forum suggested that I use the following
Type Header.txt>FinalFile.txt
Type Data.txt>>FinalFile.txt
Type Footer.txt>>FinalFile.txt

This seems to working..Atleast for now...Still I couldnt able to figure out
whats wrong with the batch file.

Thanks and Regards,
Karunakaran



"Sue Hoegemeier" wrote:


Possibly how you are calling the batch file. The Win32
Process should be something like:
Win 32 Process: cmd.exe
Parameters: /c copy D:\Header.txt+D:\Data.txt
D:\FinalFile.txt
Enable the multiphase data pump, write the header in the Pre
Source Data phase. You can find some notes on it's usage at:
http://www.sqldts.com/default.aspx?t...&i=282&p=1&a=7

-Sue

On Mon, 4 Apr 2005 02:07:03 -0700, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:


Hello Sue,

When I mean the connection is not closed, I mean by not closing the
enterprise manager. Well now whether irrespective of whether I close the
enterprise manager or not still I could able to get this work. Sometimes the
batch does what its supposed to do sometimes the final file is still blank
nothing gets written to it.

Many posts says the easier way to achieve header and footer is to use
multiphase data pump but I dont find any code snippets which does it.

Any pointers towards it?

Thanks and Regards,
Karunakaran

"Sue Hoegemeier" wrote:


Not really enough information to make a guess. What do you
mean by it runs when the connection is not closed?

-Sue

On Thu, 31 Mar 2005 23:55:03 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:


Hi,

The DTS package works fine for the first time and subsequent runs when the
connection is not closed. When I close the Enterprise Manager and execute the
package again later everthing works fine till the batch process during the
batch process the files are not copied to one file. Any ideas what could be
the problem.

Thanks and Regards,
Karunakaran

"Karunakaran" wrote:


Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:


There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:


Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran





Reply With Quote
  #10  
Old   
Karunakaran
 
Posts: n/a

Default Re: Appending to a text file in Sql DTS - 04-05-2005 , 11:55 PM



Thanks Simon.
That does work.

Karunakaran

"Simon Worth" wrote:

Quote:
Another problem you may encounter is when you exit and reopen EM, you
lose the path for the current working directory of the batch file, so
you need to specify where you want the batch file to copy from.
use the cd command to switch to the directory where your files are located.
IE -
REM Begginng of batch file
C:
cd Temp --You are now in the temp directory on your C: drive

Simon Worth

Karunakaran wrote:
The batch file(sqlbatch.bat) has the following
copy/b D:\Header.txt+D:\Data.txt+ D:\FinalFile.txt

Win32 Process
I just call the batch file sqlbatch.bat

Other one from other forum suggested that I use the following
Type Header.txt>FinalFile.txt
Type Data.txt>>FinalFile.txt
Type Footer.txt>>FinalFile.txt

This seems to working..Atleast for now...Still I couldnt able to figure out
whats wrong with the batch file.

Thanks and Regards,
Karunakaran



"Sue Hoegemeier" wrote:


Possibly how you are calling the batch file. The Win32
Process should be something like:
Win 32 Process: cmd.exe
Parameters: /c copy D:\Header.txt+D:\Data.txt
D:\FinalFile.txt
Enable the multiphase data pump, write the header in the Pre
Source Data phase. You can find some notes on it's usage at:
http://www.sqldts.com/default.aspx?t...&i=282&p=1&a=7

-Sue

On Mon, 4 Apr 2005 02:07:03 -0700, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:


Hello Sue,

When I mean the connection is not closed, I mean by not closing the
enterprise manager. Well now whether irrespective of whether I close the
enterprise manager or not still I could able to get this work. Sometimes the
batch does what its supposed to do sometimes the final file is still blank
nothing gets written to it.

Many posts says the easier way to achieve header and footer is to use
multiphase data pump but I dont find any code snippets which does it.

Any pointers towards it?

Thanks and Regards,
Karunakaran

"Sue Hoegemeier" wrote:


Not really enough information to make a guess. What do you
mean by it runs when the connection is not closed?

-Sue

On Thu, 31 Mar 2005 23:55:03 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:


Hi,

The DTS package works fine for the first time and subsequent runs when the
connection is not closed. When I close the Enterprise Manager and execute the
package again later everthing works fine till the batch process during the
batch process the files are not copied to one file. Any ideas what could be
the problem.

Thanks and Regards,
Karunakaran

"Karunakaran" wrote:


Thanks for the input. It did worked. I have posted the data flow in
http://asia.geocities.com/vij_karan/dtsflow.jpg

Let me know if there are any suggestions. Any pointers towards Multiphase
Datapump would be appreciated.

Karunakaran

"Sue Hoegemeier" wrote:


There are a few ways you could do this. You can create two
files: a header file and the data file. Then you can combine
the files into the final file using the DOS copy command
with something like:
COPY Header.txt + Data.Txt
You can also combine the two files using ActiveX script and
FileSystemObject.
You could use a SQL statement that unions the header, and
data info
You could also use the Multiphase Data Pump functionality to
create header and/or trailers for files.
The first option is often easier to do.

-Sue

On Tue, 29 Mar 2005 03:31:04 -0800, "Karunakaran"
Karunakaran (AT) discussions (DOT) microsoft.com> wrote:


Hi,

I need to export some data to a text file from sql server. I'm using Sql DTS
to do this. I also need to have a header in the text file followed by the
data exported from the sql database. I created a text file with header then
used dts to export but the header gets deleted when the dts exports the
file...so is there anyway to append the datas exported by sql dts to the text
file.

Thanks and Regards,
Karunakaran






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.