TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
SQL Server Query to Get the Max +1 ID from a Table
Bineesh Viswanath
May 24
2016
Code
988
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
SELECT
max
(
cast
(column_name
as
int
)) + 1
FROM
table_name
Lets look at the real time example:
I have a table named PRODUCTS. If want to get the Max +1 ProductID(PK) from this table, can use the following code:
SELECT
max
(
cast
(ProductID
as
int
)) + 1
FROM
PRODUCTS
Max +1 ID
SQL Query
SQL Server