You could design your database table using an IDENTITY
column. The database will assign a next value for the inserted row. You can access the value using one of: SCOPE_IDENTITY
, @@IDENTITY
or IDENT_CURRENT
. More can be found here: MSDN-Identity.
To know the difference between SCOPE_IDENTITY
and @@IDENTITY
see here.
solved Call the maximum from SQL table to textbox