Friday, June 28, 2013

nvarchar(n) and nvarchar(max) different datatypes?

Hi Everyone,


I recently tried what I thought should have been a simple operation:


alter table MY_TBL alter column COL1 nvarchar(max) --currently nvarchar(500)


to my surprise it complained about indexes containing this column:


ALTER TABLE ALTER COLUMN COL1 failed because one or more objects access this column.


double checking BOL, it seemed like this shouldn't have occurred. Quote from BOL:


The modified column cannot be any one of the following:


...


Used in an index, unless the column is a varchar, nvarchar, or varbinary data type, the data type is not changed, the new size is equal to or larger than the old size, and the index is not the result of a PRIMARY KEY constraint.


a bit more digging, and I found some people saying that nvarchar(n) and nvarchar(max) were two different datatypes, however BOL makes no such claims:


http://msdn.microsoft.com/en-us/library/ms186939.aspx


can anyone point me in a right direction? Are they two different datatype? If so where is this documented, and if they are not why does the alter statement fail?


TIA,



Mordechai




Mordechai Danielov


No comments:

Post a Comment