Avatar of gaurav sharma
gaurav sharma
 asked on

SQL insert statement

I have a table 'test' with columns

Id,          name,          notes,         definition,      url,      created_on      updated_on
6232      samxx      xxx              xxx              xxx       xxx                          xxx

so now using cursor I want to insert 10,000 rows into 'test' table with same values. As"id" is the identity
column it will generate Id'd automatically.
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
Jim Horn

8/22/2022 - Mon
Jim Horn

Eyeballeth thy article on SQL Server:  T-SQL recipe to create a million sample people, which is an image and code-heavy tutorial on how to spin up sample data using cursors and random numbers/names/demographics.

If you like what you see please click the big 'Was this article helpful?' button at the the bottom.

Good luck.
Jim
gaurav sharma

ASKER
Hey jimThanks for the reply and yes it was intended to do using cursor.. and also I have to insert this 10000 rows for an  existing table lets say I have to insert it from 5000( it has already 5000 rows in it)
Anthony Perkins

Is there some reason you want to do it in a loop?  Why not do it with a single INSERT statement?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Anthony Perkins

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

Why do you need a cursor when you can do it in one shot INSERT?
Jim Horn

Curiosity overwhelms me ...

1.

Why did you accept the one line comment you did, which is essentially a copy of an earlier comment, and not any of the more detailed solutions provided?

2.

Also, why are you asking another question inside a question that you've already selected an answer?