SQL Server, Converting NTEXT to NVARCHAR(MAX)

后端 未结 5 751
太阳男子
太阳男子 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:44

    If you can't get scheduled downtime....

    create two new columns: nvarchar(max) processedflag INT DEFAULT 0

    Create a nonclustered index on the processedflag

    You have UPDATE TOP available to you (you want to update top ordered by the primary key).

    Simply set the processedflag to 1 during the update so that the next update will only update where the processed flag is still 0

    You can use @@rowcount after the update to see if you can exit a loop.

    I suggest using WAITFOR for a few seconds after each update query to give other queries a chance to acquire locks on the table and not to overload disk usage.

提交回复
热议问题