Reputation: 570
I have a column in SQL Server that is varchar(MAX)
. The column has been populated with that data type. I now want to convert the column to nvarchar(MAX)
to accept unicode characters.
Is there any data loss when I convert this column from varchar(MAX)
to nvachhar(MAX)
?
Upvotes: 3
Views: 2426
Reputation: 453298
Every character that can be represented in varchar
is also representable in nvarchar
.
The only possible data loss issue would be if you have any varchar(max)
values that are already greater than 1GB.
In most collations nvarchar
uses 2 bytes per character and varchar
uses 1 byte per character. Doubling the string length of a string > 1 GB would obviously take you over the 2GB limit.
Even then I would expect an error message rather than silent truncation but possibly it might silently fail under some settings such as ANSI_WARNINGS OFF
.
Upvotes: 6