Changing a data column from varchar(max) to nvarchar(max) in SQL Server 2008

sql-server-2008

Solution

You can just use standard syntax to alter the table:

ALTER TABLE some_table ALTER COLUMN some_column nvarchar(max)

You will probably want to rebuild any indices however, to make sure they work as expected.

Problem

I have to change the data type in a SQL Server 2008 table from varchar(max) to nvarchar(max). This table has data in it. Is there a way to change the data type without losing the data?

Original source