How to insert a new column into the table?

  • Hai,

    I have a table with 6 columns.

    Now i will add one more column next to 4th column.

    How can i achieve it?

     

     

  • In the SQL Enterprise Manager, open table design, right click in the 4th column then click insert

  • This is difficult to achieve outside of EM - see the following link for more info. if the EM solution is not what you want.

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=5&messageid=126116&p=1

    Regards

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Ok.  <setting down soapbox>, <getting on soapbox>, <deep breath>...

    Q.  WHY do you need the new column in the middle of your table?  A.  Because someone wants to see it that way when the run SELECT * FROM ..

    #1.  SELECT * is bad.  Can lead to all sorts of nasties...

    #2.  Adding a column in the middle of a table will cause SQL to CREATE a #TEMP table with the desired order, MOVE all the data, RE-CREATE all the INDEXES, CONSTRAINTS, etc...

    #3.  Adding a column at the END does NOTHING with #2.  SQL adds the column and DONE.

    <deep calming breath>, <putting soapbox away>

    Seeing data visually especially once a table is created is NOT ALWAYS the best way regardless of "Well, the program will let me"



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Hehe, we should create a rant about this one and put it in the FAQ .

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

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