Invalid column name 'ID'.
This means that you do not have an ID column.
You should add this column to the table and set it to auto-grow, instead of writing logic to do it yourself.
As @Damien_The_Unbeliever noted, this can cause problems if two people run the script at the same time.
ALTER TABLE Anlagenteil ADD ID INT IDENTITY(1,1)
Then your SQL statement could be simple:
INSERT INTO Anlagenteil (TaId, Subtype, Name) VALUES (0, 'BdAnlageteil', 'Barcodeleser0')
And a new ID value will be added automatically.
source share