I have three tables related to each other, I want to instert 1000 rows in each of them at the same time, and I dont want to write Insert 1000 times, what should I do ?
Attachments: Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.
Well, that depends. The data you are inserting, is it in an existing table? or flat file? CSV? Do you really mean "exactly at the same time" or can it be done in the same transaction?
Answer by Yazle · Oct 22, 2019 at 12:01 PM
Hi @JohnM, thank you. The insert would be on an existing table, and by ¨at the same time¨ I mean in the same transaction
Where is the data that you are inserting coming from? You can do a simple
INSERT dbo.Table1 (id, firstname, lastnam) SELECT id, firstname, lastname from dbo.Table2;
if the data is another table. If you need to randomly generate data, that's a different story
Yeah I need to generate the data @JohnM
Answers Answers and Comments
22 People are following this question.
Inserting names, path of directory into a SQL Table
Insert "EXECUTE(@query) Into a Temp Table
Prevent duplicate insertion on table in parallel process like signal R call
Automatically insert into a 2nd table when a new data is added into another table
SQL Server Query For Average Value over a Date Period