Is it important for any of the reasons if I create column A before column B in SQL Server database? No other actions are presumed in between.
Asked
Active
Viewed 119 times
1
-
What does "important for any of the reasons" mean? What reasons? – Oded Aug 21 '12 at 18:15
-
What reason? It should not matter order, you can place the columns in the order you want, when you query. – Taryn Aug 21 '12 at 18:16
-
2There are some real [corner cases](http://stackoverflow.com/questions/894522/is-there-any-reason-to-worry-about-the-column-order-in-a-table/894545#894545) where it matters. But you are unlikely to encounter them. – Andomar Aug 21 '12 at 18:16
-
Yes, because that's the order in the specifications. – JeffO Aug 21 '12 at 19:22
1 Answers
0
See this:
Your Table Structure:
create table test (id int, name varchar(100));
Table of your customer:
create table test (name varchar(100), id int);
If you use:
insert into test values (10, 'Roger')
without specifying the order of fields in the table will cause your customer conversion error.

Roger Medeiros
- 783
- 7
- 9
-
2You just change the order which you insert. `INSERT INTO table (col1, col2)...` – Kermit Aug 21 '12 at 18:21
-
yes. this was an example to show the importance of sorting tables. – Roger Medeiros Aug 21 '12 at 18:23
-
2Agreed with @njk, you shouldn't be inserting without a column list, or promoting this type of syntax, for precisely this reason (and also because the table may have changed in the meantime). https://sqlblog.org/blogs/aaron_bertrand/archive/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list.aspx – Aaron Bertrand Aug 21 '12 at 18:24
-
@Roger: thanx, that should be enough to prove that it does matter - was it extreme case or not. The rule is - extremes do occur one way or the other. – Robert Jung Aug 22 '12 at 15:47