Sunday, March 11, 2012

Add sequence number to data

Hi all, I need some your help.

I want to add sequence number to data flow below:

Cust_Name | Month
=======================
Chonnathan | 5
Chonnathan | 4
Chonnathan | 7
Derec | 3
Derec | 9

and the result i need is:

SEQ_nbr | Cust_Name | Month
================================
1 | Chonnathan | 4
2 | Chonnathan | 5
3 | Chonnathan | 7
1 | Derec | 3
2 | Derec | 9

How can I do it in Integration Service to show like the above?

Thank you for your respones,
Chonnathan

The following are links to show how to generate a row number (i.e. similar to identity but user controlled). You would have to find logic that you are comftorable with to use these in driving the sequence number instead.

http://www.sqljunkies.com/WebLog/sqlbi/archive/2005/05/30/15684.aspx
http://www.ssistalk.com/2007/02/20/generating-surrogate-keys/

You could, of course, just use a store procedure / max(SEQ_nbr) where cust_name = ?, although this would be MUCH slower...

No comments:

Post a Comment