Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
please i want someone to help me finding how can i get the next-value or the value of the primary key from the MSSQL Table, please if anyone knows the answer i would be thankful :)
Posted

Select MAX(PrimarykeycolumnName)+1 FROM tableName


Is it ?
 
Share this answer
 
Comments
shadi_abushaar 30-Dec-10 6:28am    
THANK YOU
Hiren solanki 30-Dec-10 6:29am    
You're welcome abushaar.
If you are using sql server 2008, then you may use the following query to get the next identity value of the table
SQL
select IDENT_CURRENT('categories')+IDENT_INCR('categories')


where 'categories' is the table name for which you want next identity value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900