Home > Archive > Microsoft SQL Server Desktop Engine > October 2005 > ordinal_position









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ordinal_position
Peter Herijgers

2005-10-27, 7:56 am

After I have added a new field with:
ALTER TABLE mytable ADD mynewfield VARCHAR(15) NOT NULL DEFAULT '0'
the field is added last to the table.
Is it possible to change the ordinal_position so that the new field is not
at the end of the table?

Hugo Kornelis

2005-10-27, 7:56 am

On Thu, 13 Oct 2005 12:44:04 -0700, Peter Herijgers wrote:

>After I have added a new field with:
>ALTER TABLE mytable ADD mynewfield VARCHAR(15) NOT NULL DEFAULT '0'
>the field is added last to the table.
>Is it possible to change the ordinal_position so that the new field is not
>at the end of the table?


Hi Peter,

Only by dropping and recreating the table.

Remember that the ordinal position of a column is actually irrelevant.
You can determine the order of columns in the output by changing their
order in the SELECT clause. And if you prefer ease of use, create a view
that has the columns in the required output (though you actually should
not be using SELECT * in production code anyway!)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com