简体   繁体   中英

Changing columns from Nvarchar(max) to Nvarchar(4000) error

I am changing columns from NVARCHAR(MAX) down to NVARCHAR(4000) the column has no need to be MAX and 4000 characters should be sufficient for the column, so for performance improvements I am making the column smaller.

I thought this would be easy like so:

alter table [MyTable]
alter column [Description] nvarchar(4000) NULL

However this gives me the error:

The size (8000) given to the parameter 'Description' exceeds the maximum allowed (4000).

I dont understand this error message.. I did not specify 8000 nor did I even exceed the maximum allowed of 4000

So whats going on here?

Edit

Some columns on tables / columns are fine with NVARCHAR(4000) , others.. are not, playing with the number 4000, the error seems to suggest the maximum I can specify on particular columns is NVARCHAR(2000)

Turned out to be DDL triggers as suggested by one of the comments.

These DDL triggers are provided by a thrid party for data synchronisation to the client, so I'm not 100% sure what was going on in these triggers but I'd imagine they were getting some calculation wrong and thinking the max was nvarchar(2000) rather than nvarchar(4000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM