SQL Server, Converting NTEXT to NVARCHAR(MAX)

后端 未结 5 749
太阳男子
太阳男子 2020-12-29 13:26

I have a database with a large number of fields that are currently NTEXT.

Having upgraded to SQL 2005 we have run some performance tests on converting these to NVARC

5条回答
  •  抹茶落季
    2020-12-29 13:39

    If you can get scheduled downtime:

    1. Back up the database
    2. Change recovery model to simple
    3. Remove all indexes from the table you are updating
    4. Add a column maintenanceflag(INT DEFAULT 0) with a nonclustered index
    5. Run: UPDATE TOP 1000 tablename SET nvarchar from ntext, maintenanceflag = 1 WHERE maintenanceflag = 0

    Multiple times as required (within a loop with a delay).

    Once complete, do another backup then change the recovery model back to what it was originally on and add old indexes.

    Remember that every index or trigger on that table causes extra disk I/O and that the simple recovery mode minimises logfile I/O.

提交回复
热议问题