INSERT INTO Table1 (Value1, ...) VALUES (@Value1, ...) SELECT @Table1ID = @@Identity INSERT INTO Table2 (Table1ID, ...) VALUES (@Table1ID, ...) -- if you have only Table2 is sufficient INSERT INTO Table2 (Table1ID, ...) VALUES (@@Identity, ...)Now you can update the view with two way:
-- view is -- SELECT Table1ID,.... FROM Table1 -- BECAUSE identity is not nullable and SQL check it before the trigger ( a bug for me ), -- it fire a error for view.Table1ID fields INSERT view (Table1ID,... ) VALUES (0,) SELECT @@IDENTITY -- THIS RETURN CORRECT NEW VALUE if Table2 have not triggered insertway 2:
-- redefine the view with this SELECT NULLIF(Table1ID,NULL) AS Table1ID,.... FROM Table1 -- Now the view field is nullable, and then you can -- update the view without fill the identity field: INSERT view (... ) VALUES (...) SELECT @@IDENTITY -- THIS RETURN CORRECT NEW VALUE if Table2 have not triggered insertFabio