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
 getting the next increment

Author  Topic 

jept
Starting Member

14 Posts

Posted - 2007-09-07 : 13:16:23
I have a table with an automatic count int. What I want to know is there an sql statement to return the next increment from the sequence. Any help would be appreciated.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-09-07 : 13:18:58
scope_identity()

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-07 : 13:19:36



SELECT SCOPE_IDENTITY()+1 AS Next_ID_In_Scope



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-09-07 : 14:09:48
quote:
Originally posted by X002548




SELECT SCOPE_IDENTITY()+1 AS Next_ID_In_Scope



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam







That would only be valid if it is incrementing by 1, right?



Future guru in the making.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-07 : 14:14:55
Yes,

You would have to know the increment value in your identity column



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -