dbTalk Databases Forums  

Add row numbers to Text file export

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


Discuss Add row numbers to Text file export in the microsoft.public.sqlserver.dts forum.



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

Default Add row numbers to Text file export - 12-01-2004 , 04:01 AM






Is there a way to possibly add rown nr's to a Text file export using DTS.
The result in the text file should read

1,FieldNr1,FieldNr2,FieldNr3,
2,FieldNr1,FieldNr2,FieldNr3,
3,FieldNr1,FieldNr2,FieldNr3,
etc

instead of

FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,

Any help will be appreciated. I am also lookign at adding the value in teh
actual query but have trouble as I am using a UNION between 2 Select
statements on 2 different views.

Thanks

Marinus



Reply With Quote
  #2  
Old   
Ilya Margolin
 
Posts: n/a

Default Re: Add row numbers to Text file export - 12-01-2004 , 07:48 AM






Marinus,

Add an identity column to the destination table.

Ilya

"Marinus Willemstijn" <willemma (AT) telkom (DOT) co.za> wrote

Quote:
Is there a way to possibly add rown nr's to a Text file export using DTS.
The result in the text file should read

1,FieldNr1,FieldNr2,FieldNr3,
2,FieldNr1,FieldNr2,FieldNr3,
3,FieldNr1,FieldNr2,FieldNr3,
etc

instead of

FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,

Any help will be appreciated. I am also lookign at adding the value in teh
actual query but have trouble as I am using a UNION between 2 Select
statements on 2 different views.

Thanks

Marinus





Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Add row numbers to Text file export - 12-01-2004 , 01:21 PM



Ilya.

I think we are going from SQL Server to a text file so there is no
Destination table.

You can use a Global Variable that counts in the Active Script transform to
do this.

The problem will be that your Text File needs this column viewable when your
create it so what you can do is this

SELECT.................., 'Dummy' as RowNum
FROM.............................

You then have a text file defined correctly

For the purposes of your transforms however you do not use the Source RowNum

You can populate the destination through the incrementing of a Global
variable.

HTH


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Ilya Margolin" <ilya_no_spam_ (AT) unapen (DOT) com> wrote

Quote:
Marinus,

Add an identity column to the destination table.

Ilya

"Marinus Willemstijn" <willemma (AT) telkom (DOT) co.za> wrote in message
news:cok4ps$53t$1 (AT) ctb-nnrp2 (DOT) saix.net...
Is there a way to possibly add rown nr's to a Text file export using DTS.
The result in the text file should read

1,FieldNr1,FieldNr2,FieldNr3,
2,FieldNr1,FieldNr2,FieldNr3,
3,FieldNr1,FieldNr2,FieldNr3,
etc

instead of

FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,

Any help will be appreciated. I am also lookign at adding the value in
teh
actual query but have trouble as I am using a UNION between 2 Select
statements on 2 different views.

Thanks

Marinus







Reply With Quote
  #4  
Old   
Marinus Willemstijn
 
Posts: n/a

Default Re: Add row numbers to Text file export - 12-01-2004 , 10:39 PM



Guys

Thanks for your feedback. Allan you are right - there is no destination
table beng a Text file. I will try and go read up on the Active Scripting as
I have not yet done it before (Delphi programmer!).

Any resources?

Thanks again for your kind help.

Marinus


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Ilya.

I think we are going from SQL Server to a text file so there is no
Destination table.

You can use a Global Variable that counts in the Active Script transform
to
do this.

The problem will be that your Text File needs this column viewable when
your
create it so what you can do is this

SELECT.................., 'Dummy' as RowNum
FROM.............................

You then have a text file defined correctly

For the purposes of your transforms however you do not use the Source
RowNum

You can populate the destination through the incrementing of a Global
variable.

HTH


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Ilya Margolin" <ilya_no_spam_ (AT) unapen (DOT) com> wrote in message
news:umFkNw61EHA.4028 (AT) TK2MSFTNGP15 (DOT) phx.gbl...
Marinus,

Add an identity column to the destination table.

Ilya

"Marinus Willemstijn" <willemma (AT) telkom (DOT) co.za> wrote in message
news:cok4ps$53t$1 (AT) ctb-nnrp2 (DOT) saix.net...
Is there a way to possibly add rown nr's to a Text file export using
DTS.
The result in the text file should read

1,FieldNr1,FieldNr2,FieldNr3,
2,FieldNr1,FieldNr2,FieldNr3,
3,FieldNr1,FieldNr2,FieldNr3,
etc

instead of

FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,

Any help will be appreciated. I am also lookign at adding the value in
teh
actual query but have trouble as I am using a UNION between 2 Select
statements on 2 different views.

Thanks

Marinus









Reply With Quote
  #5  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Add row numbers to Text file export - 12-02-2004 , 12:21 AM



Oh yes


www.SQLDTS.com

++

This Newsgroup is very good for your troubles.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Marinus Willemstijn" <willemma (AT) telkom (DOT) co.za> wrote

Quote:
Guys

Thanks for your feedback. Allan you are right - there is no destination
table beng a Text file. I will try and go read up on the Active Scripting
as
I have not yet done it before (Delphi programmer!).

Any resources?

Thanks again for your kind help.

Marinus


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:uTqzcq91EHA.3336 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Ilya.

I think we are going from SQL Server to a text file so there is no
Destination table.

You can use a Global Variable that counts in the Active Script transform
to
do this.

The problem will be that your Text File needs this column viewable when
your
create it so what you can do is this

SELECT.................., 'Dummy' as RowNum
FROM.............................

You then have a text file defined correctly

For the purposes of your transforms however you do not use the Source
RowNum

You can populate the destination through the incrementing of a Global
variable.

HTH


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Ilya Margolin" <ilya_no_spam_ (AT) unapen (DOT) com> wrote in message
news:umFkNw61EHA.4028 (AT) TK2MSFTNGP15 (DOT) phx.gbl...
Marinus,

Add an identity column to the destination table.

Ilya

"Marinus Willemstijn" <willemma (AT) telkom (DOT) co.za> wrote in message
news:cok4ps$53t$1 (AT) ctb-nnrp2 (DOT) saix.net...
Is there a way to possibly add rown nr's to a Text file export using
DTS.
The result in the text file should read

1,FieldNr1,FieldNr2,FieldNr3,
2,FieldNr1,FieldNr2,FieldNr3,
3,FieldNr1,FieldNr2,FieldNr3,
etc

instead of

FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,

Any help will be appreciated. I am also lookign at adding the value in
teh
actual query but have trouble as I am using a UNION between 2 Select
statements on 2 different views.

Thanks

Marinus











Reply With Quote
  #6  
Old   
Ilya Margolin
 
Posts: n/a

Default Re: Add row numbers to Text file export - 12-02-2004 , 08:09 AM



My mistake.

Using activeX is one way. The following works as well. Use Execute SQL task
to create a global temp table with an additional identity column:

select *
,identity(int, 1,1) as RowID
into ##WithIdentity
from <Source table>

In the Transformation task specify ##WithIdentity as a source.

Ilya

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Oh yes


www.SQLDTS.com

++

This Newsgroup is very good for your troubles.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Marinus Willemstijn" <willemma (AT) telkom (DOT) co.za> wrote in message
news:com6ai$djn$1 (AT) ctb-nnrp2 (DOT) saix.net...
Guys

Thanks for your feedback. Allan you are right - there is no destination
table beng a Text file. I will try and go read up on the Active
Scripting
as
I have not yet done it before (Delphi programmer!).

Any resources?

Thanks again for your kind help.

Marinus


"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:uTqzcq91EHA.3336 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Ilya.

I think we are going from SQL Server to a text file so there is no
Destination table.

You can use a Global Variable that counts in the Active Script
transform
to
do this.

The problem will be that your Text File needs this column viewable when
your
create it so what you can do is this

SELECT.................., 'Dummy' as RowNum
FROM.............................

You then have a text file defined correctly

For the purposes of your transforms however you do not use the Source
RowNum

You can populate the destination through the incrementing of a Global
variable.

HTH


--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Ilya Margolin" <ilya_no_spam_ (AT) unapen (DOT) com> wrote in message
news:umFkNw61EHA.4028 (AT) TK2MSFTNGP15 (DOT) phx.gbl...
Marinus,

Add an identity column to the destination table.

Ilya

"Marinus Willemstijn" <willemma (AT) telkom (DOT) co.za> wrote in message
news:cok4ps$53t$1 (AT) ctb-nnrp2 (DOT) saix.net...
Is there a way to possibly add rown nr's to a Text file export using
DTS.
The result in the text file should read

1,FieldNr1,FieldNr2,FieldNr3,
2,FieldNr1,FieldNr2,FieldNr3,
3,FieldNr1,FieldNr2,FieldNr3,
etc

instead of

FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,
FieldNr1,FieldNr2,FieldNr3,

Any help will be appreciated. I am also lookign at adding the value
in
teh
actual query but have trouble as I am using a UNION between 2 Select
statements on 2 different views.

Thanks

Marinus













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.