I need to insert a data into a DB using query like this one:
INSERT INTO Table1
(aID)
VALUES
(select aID from Table2 where aID="aID"))
The problem is that if Table2 doesn’t have the aID I need to update it with it and extract the newly created ID. Is there a SQL command that automatically does it?
Your question is kinda all over the map…
The problem is that if Table2 doesn’t have the aID I need to update it with it – what do mean by this?
If it doesn’t exist you got to insert it …rght?
Having said that, you need to write a stored-procedure to achieve your objective…and also set “aID”…to be an auto-incremental,seeded Identifier column type
Let me know if you need elaboration