/*This code demonstrates the fact that you can't use composable DML to insert into a table that has a FK*/
USE tempdb
CREATE TABLE [TableWithPK] ([col1] INT PRIMARY KEY);
CREATE TABLE [TableWithFK] ([col1] INT REFERENCES [TableWithPK]([col1]));
/*Following statement fails with error:
Msg 356, Level 16, State 1, Line 17
The target table 'TableWithFK' of the INSERT statement cannot be on either side of a (primary key, foreign key) relationship when the
FROM clause contains a nested INSERT, UPDATE, DELETE, or MERGE statement. Found reference constraint 'FK__TableWithF__col1__2D27B809'.
*/
INSERT [TableWithFK]([col1])
SELECT [col1]
FROM (
INSERT [TableWithPK]([col1])
OUTPUT [INSERTED].[col1]
VALUES(1)
)insert_out
;