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)
 Add Identity Increment per user

Author  Topic 

sirmoreno
Starting Member

3 Posts

Posted - 2007-09-11 : 08:50:23
Hi
I have a Jobs Table: Job_ID,User_ID,Job_Info,...
Job_ID is the Primary Key.
I want to add [Job_ID_PerUser] so I wiil get:
Job_ID Job_ID_PerUser User_ID
1 1 A
2 1 B
3 1 C
4 2 A
5 3 A
6 2 C
Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-11 : 08:58:31
Read about Row_number function in sql server help file

Madhivanan

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

sirmoreno
Starting Member

3 Posts

Posted - 2007-09-11 : 09:07:28
Sorry but I dont see how Row_Number() can help me here.
I want to add a specific job identity per user
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-11 : 09:26:36
Yes. Use ROW_NUMBER ( ) OVER ( [ <partition_by_clause> ] <order_by_clause> )

http://msdn2.microsoft.com/en-us/library/ms186734.aspx

Madhivanan

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

sirmoreno
Starting Member

3 Posts

Posted - 2007-09-11 : 10:35:25
thanks
Go to Top of Page
   

- Advertisement -