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
 General SQL Server Forums
 New to SQL Server Programming
 Creating a Sequence Number

Author  Topic 

IsaacSMASH
Starting Member

2 Posts

Posted - 2011-09-16 : 10:52:17
Morning all,
I'm trying to use a Microsoft Access pass through query to hit a SQL server database. I'm trying to sequence number phone records where there is a single unique identifier for each person. Because there was no sequence number put in the table and the description is a free format field I cannot find another way to easily automate providing single record datasets to my customers.
I would like to know if it is possible to sequence each person 1,2,3...etc individually depending on the number of contact numbers we have for them and reset the sequence back to 1 for each person.

I have tried working using extra steps in Access and using a CASE statement in SQL and have nothing. I was hoping there was an interval option where I can point it towards my unique identifier and have it reset when that changes.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-16 : 12:00:03
i think what you're looking at is ROW_NUMBER() function. see below
http://msdn.microsoft.com/en-us/library/ms186734.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

IsaacSMASH
Starting Member

2 Posts

Posted - 2011-09-20 : 11:49:34
Thanks for the response this worked perfectly.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-20 : 12:06:44
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-09-23 : 06:13:35
Also see what you can do with row_number() function
http://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx

Madhivanan

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

- Advertisement -