I have a stored proc that executes insert onto 4 tables on SQL Server database. These 4 tables have exactly the same structure. How can I perform the insert at a time?
Maybe something like:
INSERT INTO Table1, Table2, Table3, Table4
VALUES (@p1, @p2, ....... @pn)
There isnt a way – this is four separate inserts.
You could put all results into a single temp table and then select into the other tables to reduce the code, but you cannot do all four at once.
See:
Transact-sql insert in two tables at once?