I want to insert 10000 records in a table and i am currently writing this code in sql server 2005
declare @n decimal(10,0);
set @n = 0;
while ( @n < 10000)
begin
insert into table1 values (@n+1)
set @n = @n + 1
end
in the above code insert command performs 10000 times is there any single command exists to do so.
Also you can use sys objects to your advantage:
INSERT INTO table1(n)
SELECT TOP 10000 ROW_NUMBER() OVER(ORDER BY a.object_id) AS n FROM sys.objects a CROSS JOIN sys.objects b
GO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With