Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Appending new variable

Author  Topic 

amits
Starting Member

6 Posts

Posted - 2010-10-05 : 01:37:34
I have a set of data having account numbers and customer name.There are instances where the data is duplicated. I want to append a new reference number for all records so that duplicate accoounts have the same reference number. For example account X001 belongs to Mr Smith and it appears twice. For both records I want to have a unique reference number 1.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-05 : 01:58:29
You can use the ROW_NUMBER() function for this. If you can provide a better data example, we can provide a solution.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-05 : 06:50:47
Use dense_rank() function

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

amits
Starting Member

6 Posts

Posted - 2010-10-05 : 21:40:09
Thanks Madhivanan...it worked
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-06 : 04:42:24
quote:
Originally posted by amits

Thanks Madhivanan...it worked


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -