SQL Server optimization: Create and Alter Table.

Anybody knows if there is any advantage in creating table with all columns using one Create Table statement comparing to adding most of the columns one at a time using Alter Table statement.

Thanks in advance.
quasar_eeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Göran AnderssonCommented:
A strange thing to optimize, as it should not be something that you do in regular data manipulation...

It would be slightly faster to create the table in one go. Each alter table statement would need to get an exclusive lock on the table, so there is a bit of overhead.
0

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
shivanshuvermaCommented:
this is quite difficult to create all column at a time in a table.so you need to alter table commend.therefore both  are good.
0
gothamiteCommented:
Definitely create the table in one go. Is there a specific reason why you would want to add columns separately? Are they dynamically defined or something?

If you add columns one by one as well as the locks comment by @GreenGhost any indexes you have on the table will have to be rebuilt which could take extra time
0
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 2008

From novice to tech pro — start learning today.