简体   繁体   English

SSMS-导入nvarchar(max)仍然会出现截断错误

[英]SSMS - Importing into nvarchar(max) still giving truncate errors

I'm using SSIS to import an Excel table into SQL Server. 我正在使用SSIS将Excel表导入SQL Server。 The field in the SQL Server table is set as nvarchar(max) but it still gives me Truncate Error. SQL Server表中的字段设置为nvarchar(max),但它仍然给我截断错误。 The column that I want to import can have any number of characters, it could be 1 or it could be 10,000. 我要导入的列可以有任意数量的字符,可以是1或10,000。 It's a free-text filed without any limitations. 它是自由文本格式,没有任何限制。

在此处输入图片说明 在此处输入图片说明

SSIS samples your data to get an idea of each column. SSIS对您的数据进行采样,以了解每一列。 It will use the max length of the sample to determine the "proper" field size. 它将使用样本的最大长度来确定“适当”字段的大小。 Of course this causes constant issues. 当然,这会引起持续的问题。

Can you add something to order your data to make the longest first? 您可以添加一些命令来排序数据以使最长的时间最长吗?

ORDER BY LEN(LongFIELD) DESC 

Check out StackExchange for more info: Text was truncated or one or more characters had no match in the target code page When importing from Excel file 请查看StackExchange以获取更多信息: 从Excel文件导入时,文本已被截断或目标代码页中的一个或多个字符不匹配

进入Excel Source Component的Advanced设置,然后手动设置Output列的长度。

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

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