简体   繁体   English

将列从 Nvarchar(max) 更改为 Nvarchar(4000) 错误

[英]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.我正在将列从NVARCHAR(MAX)更改为NVARCHAR(4000)列不必是 MAX 并且 4000 个字符应该足以用于列,因此为了提高性能,我正在使列更小。

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).赋予参数“描述”的大小 (8000) 超过了允许的最大值 (4000)。

I dont understand this error message.. I did not specify 8000 nor did I even exceed the maximum allowed of 4000我不明白这个错误消息..我没有指定8000也没有超过允许的最大值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)表/列上的某些列可以使用NVARCHAR(4000) ,而其他.. 则不是,使用数字 4000,错误似乎表明我可以在特定列上指定的最大值是 NVARCHAR(2000)

Turned out to be DDL triggers as suggested by one of the comments.正如其中一条评论所建议的那样,原来是 DDL 触发器。

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)这些 DDL 触发器是由第三方提供的,用于将数据同步到客户端,所以我不能 100% 确定这些触发器中发生了什么,但我想他们计算错误并认为最大值是nvarchar(2000)而不是nvarchar(4000)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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