How can I use sql to insert columns into a table, and control the order at which they go in the table? I want to insert columns at the beginning of a table, and by default, sql puts them at the end of the table...
A clustered index will control the way data is organized on disk. However, that does not mean that you are assured of returning the data in the same order. To insure that you will return data in the order that you want, you MUST use the "OREDER BY" clause in your query.
- Paul
- If at first you don't succeed, find out if the loser gets anything.
Do not mess with the column order. Add new columns with the alter table command which you can look up in BOL. Changing the column order (by dropping and recreating the table or using enterprise manager which does the same thing) is a bad practice which can result in breaking existing code. Instead of messing with column order you should alwys selct only the columns you want in the order you want them in the results rather than using select *.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.