An INSERT statement with SELECT in DB2 and SQL Server
I have a table ITEMS with the following columns:
I will like to insert a new record in the table and the next value of ID should be the max +1 (25).
The script will be run in different environments so the last value maybe different.
I will like to create an INSERT statement to be something like this:
INSERT INTO ITEMS (ID, DESCRIPTION)
VALUES (SELECT MAX(ID)+1 FROM ITEMS, ‘GHI’)
The same statement will be executed for a DB2 and SQL Server db.
Is the above statement valid in both db?