SQL: Mass insert or Create a table with all the same values

basically I want to put say 1,000,000 rows with all the same data for each column into a table. I don't want to use a while loop with an insert; it will take to long.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Eyeballeth thy article on SQL Server:  T-SQL recipe to create a million sample people
Uses Itzik Ben-Gan's method to countinously double the size of a set until you get to a million.  Find 'Then let’s create our final SAMPLE_CUSTOMER table,' then read down.  Runs fast.
Then uses a cursor and lots of random numbers to create names, addresses, SSN's, phone numbers, etc.  Really dogs, but does the job.

I presented this at a SQL Saturday a couple of years ago and it went over really well.

I know you wanted to avoid the WHILE loop.  I think there are a couple of queries out there that queries various sys tables that can easily have over a million rows to more quickly spin up a set.

Hope this helps.
Ryan ChongCommented:
You can try use the command Select Into, or create a similar table, and then run the insert statement.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
ButtonDownBobby, do you still need help with this question?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.