Groups | Blog | Home
all groups > sql server data warehouse > march 2007 >

sql server data warehouse : SSIS - adding line numbers to imported data



sqllearner NO[at]SPAM hotmail.com
3/5/2007 10:45:58 AM
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?
SQL Learner
3/5/2007 2:47:31 PM
[quoted text, click to view]

Thanks Simon and Alan
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]

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]
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]

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]
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]
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

AddThis Social Bookmark Button