Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Question Unanswered: Adding column to a table before an existing column

    I simply need the ability using SQL to add columns in an existing table before (or after) columns that already exist.

    The MS SQL implementation of ALTER TABLE doesn't seem to provide the before or after placement criteria I require. How is this done in MS SQL using SQL or is there a stored procedure I can use?

    Thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You can do this easily through Enterprise Manager in the table design form. If you must do this using TSQL, then change your table through Enterprise Manager and instead of saving your changes use the button in the menu bar to script the changes. Copy the code and paste it into your application with whatever modifications you require.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Why bother?

    If the table has volumes of data, it'll take awhile....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  4. #4
    Join Date
    Feb 2004
    Location
    San Antonio, TX
    Posts
    565
    i agree
    there is no reason to need to add a column before another column because you can change the order of the columns in the select list of your select statement.

    it really doesnt matter where the columns exist.

  5. #5
    Join Date
    May 2004
    Posts
    3

    Adding column to a table before an existing column

    Actually, this can be very useful. Lets say your loading data using bulk insert. Your source data for the given table had columns in a particular order and your target has a different order. You have no control over the datafile creation process.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You can BULK INSERT in to a view. Changing a table structure to match an incoming data set is having the tail wag the dog don't you think?

    What do you do if you get another file in another format - change the table again?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •