I have this situation,
INSERT INTO TABLE1()...
--Get the primary key from the above insert
SELECT @@identidy
INSERT INTO TABLE2()...
The auto generated primary key has to be a foreign key in TABLE 2. How can I construct my second INSERT to have the value of @@identity?
This doesn't seem to work,
INSERT INTO TABLE1 (user_id, name) (@@identity, 'ABC')
I get an error saying Must declare variable '@@identidy'.
Cheers!!