how to get the next autoincrement value in sql

后端 未结 10 993
时光取名叫无心
时光取名叫无心 2020-12-16 13:21

I am creating a winform application in c#.and using sql database.

I have one table, employee_master, which has columns like Id, name, address

10条回答
  •  忘掉有多难
    2020-12-16 13:52

    To get the next auto-increment value from SQLServer :

    This will fetch the present auto-increment value.

    SELECT IDENT_CURRENT('table_name');
    

    Next auto-increment value.

    SELECT IDENT_CURRENT('table_name')+1; 
    

    ------> This will work even if you add a row and then delete it because IDENT_CURRENT returns the last identity value generated for a specific table in any session and any scope.

提交回复
热议问题