I am working on a database that is about 6Gb. I need to convert all the non unicode columns to unicode e.g. change all varchar to nvarchar.
I had scripted this using ALTER statements like ALTER TABLE mytable ALTER COLUMN mycolumn nvarchar(...) but I found the database size increased massively afterwards. The .mdf file grew to over 70Gb which surprised me. I know that unicode takes x2 times the space of varchar but even if the database was all varchar and was converted I would expect it’s maximum size to be 12Gb.
I tried to shrink the database and files to see if it was unallocated space but this had little effect and sp_spaceused indicated there was not an excessive amount of unallocated space.
Does anyone know why the database would have grown so large? I’m very keen to understand what would have caused this.
I have managed to change the column datatypes to unicode by creating a new database scripted from the old database and importing all the data and the result was an increase in size of only 1Gb, so I’d like to understand why altering the column datatypes caused such growth.
Have you checked if the increased size it’s on the log file? If this is the problem, truncate it by making backups of your db. This is the most probable problem.