How to reduce size of SQL Server table that grew from a datatype change

前端 未结 5 1591
刺人心
刺人心 2020-12-05 04:58

I have a table on SQL Server 2005 that was about 4gb in size.

(about 17 million records)

I changed one of the fields from datatype char(30) to <

5条回答
  •  [愿得一人]
    2020-12-05 05:41

    Alternatively, you could do a full table rebuild to ensure there's no extra data hanging around anywhere:

    CREATE TABLE tmp_table();
    GO
    INSERT INTO tmp_table() SELECT  FROM ;
    GO
    DROP TABLE 
    ; GO EXEC sp_rename N'tmp_table', N'
    '; GO

    Of course, things get more complicated with identity, indexes, etc etc...

    提交回复
    热议问题