How to modify a table Without dropping
-
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"
-
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"
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
-
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"
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
-
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
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.