get the next value of identity

Hi

how can i now in sql.. what will it be the next value of identity



Answer this question

get the next value of identity

  • Stephen McCloskey

    yes its autoincrement so.. can you give example



  • F.Chen

    try: SELECT MAX(ID_COLUMN) FROM TABLE_NAME
    This gives the current max, so add 1 for the next value.

  • phillihp

    if your identity is autoincrement then is (Identity + 1)

  • dariusj18

    SELECT SCOPE_IDENTITY() + 1, but it only works after an insert.


  • Mathiarasi

    You can't.


  • John Hart_MS

    By using name of the table as an argument to IDENT_CURRENT and IDENT_INCR functions you can figure out what will be next value of identity. Following sample shows next value of identity that will be used if you add a record to Employee table in Northwind database:

    USE Northwind

    GO

     

    SELECT IDENT_CURRENT('Employees') + IDENT_INCR('Employees')

     You can not simply add 1 to a return value of Max ID because although uncommon it is possible to set a increament of 2. So you can simply add return values from these two functions, which SQL Server engine uses behind-the-scenes anyways.


  • get the next value of identity