Is it possible to add a column to a table using Query Analyzer (and
Transact-SQL) at a particular position? That is, if I have columns called
ColA and ColC, can I add a column called ColB so that when using sp_columns
they appear in alphabetical order. It's just that using Enterprise Manager
its possible to insert a column at a particular location and I wondered if
this could be reproduced using Transact-SQL? (Cant see anything in Books
Online.)
No. And it's not really possible in EM either. EM creates a new table with
the columns in the "position" you specify, then copies all of the old data
in, drops the old table, and re-names the new table.
Why do you need them ordered a specific way?
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
"phil" <phil@.discussions.microsoft.com> wrote in message
news:1BA1B8AA-6E30-4207-B626-296A260BC5B9@.microsoft.com...
> Is it possible to add a column to a table using Query Analyzer (and
> Transact-SQL) at a particular position? That is, if I have columns called
> ColA and ColC, can I add a column called ColB so that when using
sp_columns
> they appear in alphabetical order. It's just that using Enterprise Manager
> its possible to insert a column at a particular location and I wondered if
> this could be reproduced using Transact-SQL? (Cant see anything in Books
> Online.)
|||I don't. Im just an obsessive, compulsive about this kind of thing
particularly when it "appears" as though its possible. Thanks, I'll try to
chill.
"Adam Machanic" wrote:
> No. And it's not really possible in EM either. EM creates a new table with
> the columns in the "position" you specify, then copies all of the old data
> in, drops the old table, and re-names the new table.
> Why do you need them ordered a specific way?
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.datamanipulation.net
> --
>
> "phil" <phil@.discussions.microsoft.com> wrote in message
> news:1BA1B8AA-6E30-4207-B626-296A260BC5B9@.microsoft.com...
> sp_columns
>
>
|||"phil" <phil@.discussions.microsoft.com> wrote in message
news:7AD0528D-4628-403E-83A3-19F71C89F09B@.microsoft.com...
> I don't. Im just an obsessive, compulsive about this kind of thing
> particularly when it "appears" as though its possible. Thanks, I'll try to
> chill.
Sounds like a good plan. Remember that columns are never supposed to be
ordered according to the Relational Data Model -- the fact that you can see
them ordered in a tool like EM is a physical implementation detail coming
through. It would have saved a lot of headaches if they'd decided to
alphabetize the list instead!
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment