I have a sql statement which is a routine insert of two values into a table (values meaning fields). These are ints/nvarchars.
However, for the 3rd field of the table (which can be null), I want to insert the max number of rows in the table + 1. How can I do this?
EDIT:
Table is as such
Postcode Active ID
NULL 1 14
This code shows you how it can be done and what trouble you can get into if you need ID to be a unique value in the table. There are more situations where you might end up with duplicates. One would be that two users add rows to the table at the same time.
Result:
If you need the values to be unique you should use an identity column instead. Perhaps even make it a primary key or at least add a unique constraint on the ID column.