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.
Who is Participating?
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.
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.
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
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.

All Courses

From novice to tech pro — start learning today.