I've wrote a script that does work, but it's VERY slow (6 hours). I've been tasked with creating 10000 records, each with anywhere (randomly) up to 50 enditems, each with anywhere (randomly) up to another 50 relevant foreign key items, and then again, and again.
I think it's so very slow because of the iterative way I'm doing it.
Loop 10000
insert into tble1()
Loop 50
insert into tble2 (select top(1) from tble1 desc)
Loop 50
insert into tble3 (select top(1) from tble2 desc)
Loop 50
insert into tble4 (select top(1) from tble3 desc)
end
end
end
end
Is kind of how it looks. I know sql works best with sets instead of iteration, but is there a way to do this with relationships without this loop setup I have?