Is there a way to select inserted row? I am trying to run the following query using SqlCommand
(it is used to reserve given id in the database):
INSERT INTO tbl (id)
SELECT COUNT(*) + 1 AS id from tbl
Is there a way to return the inserted id column so I can use it in my app? Or maybe is there an easier way I can achieve this? I have to be absolutely sure I reserve the free id, even if multiple users will use the app at the same time.
Also, is there a way I can change the query to pick first free id so I can avoid gaps?