Adding a column

  • This may or may not be an easy question, but is there a way in code to add a new column in a specificied location? I know the add column code adds that column at the end of the table, I need to have it added to the middle of the table.

  • No you cannot place in a specific position. The way EM does this is by making a new table with the new column and populating from the old and scripting out the Constraints/Trieggers/etc then dropping the old table and renaming the new then applying the scripts for the toher peices. It is long and complicated and you can watch under Profiler. I suggest use a View for presentation if you want people to see in a specific order and just append to the end.

  • That would be great to use a view, but all of my insert into statements throughout my program and SP would now need to be recoded. I guess I have a lot of work ahead of me.

  • quote:


    ...insert into statements throughout my program and SP would now need to be recoded...


    AFAIK, INSERT INTO statements do not require the column list to be in the order of the columns in the table. If you are writing INSERT INTO statements without a column list, it is not a recommended practice and it may be worth your while to write them with column lists anyway...

    Just a thought,

    Jay

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply