Reputation: 1
How to auto increment an id in SQL Server whenever a new row is inserted in the table? This id is primary key of the table.
Upvotes: 0
Views: 3593
Reputation: 96640
And to return the id in your code lookup scope_identity() and the OUTPUT clause. De not use @@identity as it can return the wrong value if triggers are put on the table, therefore it is not safe to use if you value data integrity.
Upvotes: 0