Jun 16, 2005 #1 magmo Programmer May 26, 2004 291 SE Hi If I use this code... Code: SELECT MAX(ID) AS CID FROM dbo.tbl_tablename The ID is a Primary Key with Identity turned on What I would like is to retrieve the next ID number instead of the number of rows. How can I do that? Regards
Hi If I use this code... Code: SELECT MAX(ID) AS CID FROM dbo.tbl_tablename The ID is a Primary Key with Identity turned on What I would like is to retrieve the next ID number instead of the number of rows. How can I do that? Regards
Jun 16, 2005 #2 JamesLean Programmer Dec 13, 2002 3,059 GB To get the next ID that will be inserted into a table you can use: Code: SELECT IDENT_CURRENT('table') + IDENT_INCR('table') AS nextid --James Upvote 0 Downvote
To get the next ID that will be inserted into a table you can use: Code: SELECT IDENT_CURRENT('table') + IDENT_INCR('table') AS nextid --James