all groups > sql server dts > march 2007 >
You're in the

sql server dts

group:

SSIS - adding line numbers to imported data


SSIS - adding line numbers to imported data sqllearner NO[at]SPAM hotmail.com
3/5/2007 10:45:58 AM
sql server dts:
I need to import a flat file as follows:

Column1,Column2,Column3
1,2,3
4,5,6
(snip)
123,456,789
Downloaded from www.abcdef.com on 02/28/2007. Total1: 12344556
Total2:
234523 Total3: 56456 Copyright 2004-2007 by ABCDEF Group LLC. All
Rights Reserved.


The last line is some kind of signature. I have no problems uploading
data lines from 1,2,3 to 123,456,789.
The last line is ignored, which is OK.


I have 2 problems I cannot solve right now:
1. I need to upload the last line into some other staging table to do
some validation, such as to match totals against my control numbers
and to verify the date.
2. I need to have line numbers from the text in my target table:


LineNumber,Column1,Column2,Column3
1,1,2,3
2,4,5,6
(snip)
300,123,456,789


I think there should be a transformation to add line numbers, but I
cannot find any so far.


Thanks in advance. BTW, am I asking in the correct newsgroups?
Re: SSIS - adding line numbers to imported data SQL Learner
3/5/2007 2:47:31 PM
[quoted text, click to view]

Thanks Simon and Alan
Re: SSIS - adding line numbers to imported data Simon Sabin
3/5/2007 9:10:04 PM
Hello SQL,

Its easy to do in a script component,

I've done a demo of this here

http://sqlblogcasts.com/blogs/simons/archive/2007/03/05/SSIS---How-do-I-add-rownumber-line-number-to-a-data-flow.aspx

or use the component from Jamie Thomson

http://blogs.conchango.com/jamiethomson/archive/2006/09/12/SSIS_3A00_-Rank-Transform.aspx


Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons


[quoted text, click to view]

Re: SSIS - adding line numbers to imported data Allan Mitchell
3/5/2007 10:16:39 PM
You could use this if you want

Row Number Transformation
(http://www.sqlis.com/93.aspx)



--


Allan Mitchell
http://wiki.sqlis.com | http://www.sqlis.com | http://www.sqldts.com |
http://www.konesans.com



[quoted text, click to view]
Re: SSIS - adding line numbers to imported data Simon Sabin
3/5/2007 10:23:34 PM
Hello Allan,

The script component rules ;)


Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons


[quoted text, click to view]

Re: SSIS - adding line numbers to imported data Allan Mitchell
3/5/2007 10:30:15 PM
Don't get me started :->

--


Allan Mitchell
http://wiki.sqlis.com | http://www.sqlis.com | http://www.sqldts.com |
http://www.konesans.com



[quoted text, click to view]
Re: SSIS - adding line numbers to imported data Allan Mitchell
3/6/2007 12:00:00 AM
I think the article does not mean it will not label each line correctly
rather it may not number them in the order you expect them to be
numbered. Yes our component behaves in a very similar way to this code
except we allow seeding and increments.

--


Allan Mitchell
http://wiki.sqlis.com | http://www.sqlis.com | http://www.sqldts.com |
http://www.konesans.com



[quoted text, click to view]
Re: SSIS - adding line numbers to imported data SQL Learner
3/6/2007 6:42:05 AM
[quoted text, click to view]


Allan,

Is your solution similar to the following:

http://support.microsoft.com/kb/908460

If yes, I have a concern: MSDN says "The mycount column does not
necessarily reflect the actual row number in the original source."
Does your solution provide a reliable way of numbering lines in a text
file?

TIA

Re: SSIS - adding line numbers to imported data SQL Learner
3/6/2007 7:11:09 AM
[quoted text, click to view]


I'm afraid I'm not following you. I expect lines in a text file
(unlike a database table) to be numbered from top to bottom, and
anything esle is incorrect. For instance, given a file

23.2,17,5
23.1,16,4

I expect it to transform to

1,23.2,17,5
2,23.1,16,4

I think any other numbering is not correct.

TIA
Re: SSIS - adding line numbers to imported data Allan Mitchell
3/6/2007 3:15:37 PM
If the data appears into the pipeline in that order then our component
should number in tht order (order the data is seen)

--


Allan Mitchell
http://wiki.sqlis.com | http://www.sqlis.com | http://www.sqldts.com |
http://www.konesans.com



[quoted text, click to view]
Re: SSIS - adding line numbers to imported data Simon Sabin
3/6/2007 4:06:13 PM
Hello SQL,

If you have just got a flat file source then the data should be put on the
pipeline in the order the data is read from the file. Ths note covers the
fact that components may not preserve the order of the pipeline, i.e a component
may take all the rows in a buffer and output them in another order. If a
component is synchronous then it cannot alter the order of data in a pipeline.
It can remove data but not change the order.


Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons

Re: SSIS - adding line numbers to imported data Allan Mitchell
3/6/2007 4:24:07 PM

If a component is synchronous then every row that comes in will go out.
There is now swapping of buffers (Async) and you cannot stop the data
from re-emerging AFAIK.


--


Allan Mitchell
http://wiki.sqlis.com | http://www.sqlis.com | http://www.sqldts.com |
http://www.konesans.com



[quoted text, click to view]
AddThis Social Bookmark Button