How can I add a column to the begining of the table using
t-sql? I know the syntax, but it adds it as the last
column on the table.
TIA,
Vic
Hi,
No, you cant do that. Using TSQL statements (ALTER table) you cant insert a
column inbetween or first. It
always add the new column in the end.
Using Enterprise manager we can insert columns inbetween, but enterprise
manager does this in the below way
1. Export data out
2. Drop the table
3. Create the new table with new column added
4. Loads back the data.
This will not be a good mechanism if your data volume in your table is high.
Thanks
Hari
SQL Server MVP
"Vic" <vduran@.specpro-inc.com> wrote in message
news:080601c53f17$3e349bc0$a501280a@.phx.gbl...
> How can I add a column to the begining of the table using
> t-sql? I know the syntax, but it adds it as the last
> column on the table.
> TIA,
> Vic
|||> This will not be a good mechanism if your data volume in your table is
high.
Also, you should not rely on column order. In a relation, column and row
order is not defined. You should always specify column names in your DML
statements.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
No comments:
Post a Comment