Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to modify a table Without dropping

How to modify a table Without dropping

Scheduled Pinned Locked Moved Database
toolstutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SIJUTHOMASP
    wrote on last edited by
    #1

    Hai, I am having a table(Suppose Table1) with some data. After wards I have made some changes in the table so that the primary key changed and added some more columns(some references also). How I can write the script to modify the table with this change with out dropping the table. Because I need the data saved in the table. How I can write the upgradable script for that. Please show me the right way. Thanks very much. Thank You, Rahul. "Learn from Mistakes for suceess otherwise get buried with the Mistakes"

    C D 2 Replies Last reply
    0
    • S SIJUTHOMASP

      Hai, I am having a table(Suppose Table1) with some data. After wards I have made some changes in the table so that the primary key changed and added some more columns(some references also). How I can write the script to modify the table with this change with out dropping the table. Because I need the data saved in the table. How I can write the upgradable script for that. Please show me the right way. Thanks very much. Thank You, Rahul. "Learn from Mistakes for suceess otherwise get buried with the Mistakes"

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      You could use ALTER TABLE[^]


      My: Blog | Photos "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious

      1 Reply Last reply
      0
      • S SIJUTHOMASP

        Hai, I am having a table(Suppose Table1) with some data. After wards I have made some changes in the table so that the primary key changed and added some more columns(some references also). How I can write the script to modify the table with this change with out dropping the table. Because I need the data saved in the table. How I can write the upgradable script for that. Please show me the right way. Thanks very much. Thank You, Rahul. "Learn from Mistakes for suceess otherwise get buried with the Mistakes"

        D Offline
        D Offline
        Daniel Santillanes
        wrote on last edited by
        #3

        May be it's late now... but in Enterprise Manager, when you enter in 'design table', after you make the changes, there's a button in the tool bar that says Save Change Scripts, that will save a script that'll do exactly what you are asking for :). So you can run this script in another server for example. The script alters the table, it doesn't drop and remake it. daniero

        N 1 Reply Last reply
        0
        • D Daniel Santillanes

          May be it's late now... but in Enterprise Manager, when you enter in 'design table', after you make the changes, there's a button in the tool bar that says Save Change Scripts, that will save a script that'll do exactly what you are asking for :). So you can run this script in another server for example. The script alters the table, it doesn't drop and remake it. daniero

          N Offline
          N Offline
          n10sive
          wrote on last edited by
          #4

          daniero wrote:

          The script alters the table, it doesn't drop and remake it.

          Not necessarily. Depends on what you are doing. Sometimes this script will copy the data to a temp table, drop the existing table and recreate it, then rewrite the data back into it. Alot depends on what you are modifying, and whether or not default values can be used. Otherwise...great suggestion....letting sql server create the script is the best thing to do.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups