Tuesday, March 27, 2012

Adding a new column in a certain position....

Hi,
I am writing some updates scripts for a database and need to add a new
column at a specific position in the table. I am using the 'ALTER TABLE'
command but this just tags it on the end. Is there any way of doing (via
TSQL) this without rebuilding the table?
Thanks in advance,
Stuno, there isn't. but there isn't a good reason for doing this in the first
place - at least not the one i know of. why is the order of columns in base
table important to you?
dean
"Stu" <s.lock@.cergis.com> wrote in message
news:uL%230ep9KGHA.3836@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I am writing some updates scripts for a database and need to add a new
> column at a specific position in the table. I am using the 'ALTER TABLE'
> command but this just tags it on the end. Is there any way of doing (via
> TSQL) this without rebuilding the table?
> Thanks in advance,
> Stu
>
>|||Stu skrev:

> Hi,
> I am writing some updates scripts for a database and need to add a new
> column at a specific position in the table. I am using the 'ALTER TABLE'
> command but this just tags it on the end. Is there any way of doing (via
> TSQL) this without rebuilding the table?
> Thanks in advance,
> Stu
This is a common question, and the anwer is 'no' :)
Search for it on Google for example, then you'll learn that you should
not really care about in which order the columns are in a table.
/impslayer, aka Birger Johansson|||Stu,
There is no good reason (that I have come across) to need the columns in any
particular order (except, perhaps, for clarity at some stage), but
operationally, they should make no difference whatsoever.
As a side point, they may make a difference should you use the SELECT * FROM
tblMyTable, but then again, that is not good practise to do, I always state
my Selected column names, for both clarity and to ensure that should a schem
a
change occur in the underlaying table (e.g. a column added) then the same,
correct, columns are returned each time.
Hope this assists,
Tony
"Stu" wrote:

> Hi,
> I am writing some updates scripts for a database and need to add a new
> column at a specific position in the table. I am using the 'ALTER TABLE'
> command but this just tags it on the end. Is there any way of doing (via
> TSQL) this without rebuilding the table?
> Thanks in advance,
> Stu
>
>|||http://www.aspfaq.com/2528
"Stu" <s.lock@.cergis.com> wrote in message
news:uL%230ep9KGHA.3836@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I am writing some updates scripts for a database and need to add a new
> column at a specific position in the table. I am using the 'ALTER TABLE'
> command but this just tags it on the end. Is there any way of doing (via
> TSQL) this without rebuilding the table?
> Thanks in advance,
> Stu
>
>

No comments:

Post a Comment