Quantcast
Viewing latest article 2
Browse Latest Browse All 2

SQL Server 2008 – Get the next Identity Value

Question:
How to get the next Identity Value in SQL Server 2008?

Answer:
It is very simple to the get the identity value in SQL Server. Let’s see with the example below

Lets‘s create some dummy data as mentioned below …

Image may be NSFW.
Clik here to view.
01 SQL Server 2008 - Get the next Identity Value

SQL Server 2008 – Get the next Identity Value

In SQ Server, there are two functions IDENT_CURRENT and IDENT_INCR. With the help of these funtions, we can get next value Identity.

IDENT_CURRENT:
It returns the last identity value generated for a specified table or view. The last identity value generated can be for any session and any scope.

IDENT_INCR:
It Returns the increment value (returned as numeric (@@MAXPRECISION, 0)) specified during the creation of an identity column in a table or view that has an identity column.

Get the Last Identity Value as below…

Image may be NSFW.
Clik here to view.
02 SQL Server 2008 - Get the next Identity Value

SQL Server 2008 – Get the next Identity Value

Get the Identity Increment

Image may be NSFW.
Clik here to view.
03 SQL Server 2008 - Get the next Identity Value

SQL Server 2008 – Get the next Identity Value

Get the next Identity Value

Image may be NSFW.
Clik here to view.
04 SQL Server 2008 - Get the next Identity Value

SQL Server 2008 – Get the next Identity Value

Hope this help you.

The post SQL Server 2008 – Get the next Identity Value appeared first on Varinder Sandhu.


Viewing latest article 2
Browse Latest Browse All 2

Trending Articles