Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Insert new column to Existing Table Using DMO

Author  Topic 

nctran
Starting Member

1 Post

Posted - 2003-07-22 : 22:49:00
I am using DMO in delphi to create Table and modify existing table in SQL database. I can not find any info about how to insert new column into an existing table but you can add column.

By having a look at Enterprise manager you can insert column without problem.

If anyone know how Enterprise manager does it, Please help. I am sure it uses DMO as well.

I also have an additional query about Collation property of Column in the table : If anyone experienced that when you change Collation property of a Column it also changes AllowNulls property to True also.{Vise versa }

Thanks,



robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-07-22 : 23:07:48
I think the DMO methods simply map to the following calls, but what EM does in reality is:

A) Creates a new table structure with the new columns in their new positions;
B) Copies the data into the new structure;
C) Drops the old table;
D) Renames the new table to the old name

You can see these actions if you run SQL Profiler and capture T-SQL events (filtering on Application Name Like '%Enterprise%' will limit it to EM events only) Also, when you do this using EM, you break any existing dependencies that required that table. Some procedures or views may not function correctly unless you recompile or refresh their definitions.

Whether you "insert" a column into the "middle" of a table or add it to the "end", it does not affect how the table performs. Considering the side effects of inserting the column, you should just add columns; you can always fix your presentation layer and/or queries to put them wherever you like them to be.

Go to Top of Page
   

- Advertisement -