Link to home
Start Free TrialLog in
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.
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

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
Avatar of gaurav sharma
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)
Is there some reason you want to do it in a loop?  Why not do it with a single INSERT statement?
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why do you need a cursor when you can do it in one shot INSERT?
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?