I need help writing a TSQL script to modify the two column data types.
We have two columns:
- Unique identifier - & gt; Varchar (36) * * * has a primary key obligation
- xml - & gt; Nvarchar (4000)
My main concern is to produce the script ...
The table is actively used in the public, which is thousands of hits per hour She goes . Consequently, we need a script to run quickly without affecting the service on the front side. In addition, we need to be able to automatically rollback the transaction if an error occurs.
Fortunately, there are only 25 rows in the table, so I guess the update will be soon
this database is SQL Server 2005.
(FYI - Requires type change due to a third-party device which is not compatible with SQL Server's XML and unique identifier types. I have already tested the changes in Dev And there is no functional problem with the change.)
As David said, in a production database Execute a script without any backups or It is said that it is not the best idea to stop it, if you want to make changes with only few lines in one line in the same table, then you can prepare the script:
- Start Transactions
- Create a new table with the last desired structure
- Copy the data from the original table to the new table
- Rename the old table, for example, original_name_old
- Rename the new table to the original_tables_name
- Closing transactions
It will end up being a table named as the original one, but you want that with the new structure, and additio You maintain the original table with the backup name, so if you want to roll back the change, To make a simple drop of the table, you can create a script and change the name of the original.
If the table is foreign key, the script will be a bit more complicated, but it is still possible without much work.
Comments
Post a Comment