字符串截断,ANSI_WARNINGS OFF
使用 SQL Server 2008 (R2)。 我在不同的数据库中有两个表(具有相同的列数和数据类型 - 但大小不同) 。我正在将值从一个表插入到另一个表,但问题是源表有:nvarchar(200),而目标表有一个 nvarhchar(100) 类型的字段。 并且源表中的数据的字段大于 100 个字符,因此错误:
*String or binary data would be truncated is thrown.*
我尝试使用
-- SourceServer is passed in at command prompt (batch)
SET ANSI_WARNINGS OFF
GO
INSERT INTO DestinationTable(col1, col2,...)
SELECT col1, col2, ...
FROM $SourceServer.dbo.SourceTable
SET ANSI_WARNINGS ON
GO
This is 然而,抛出一个错误,如下所示: INSERT 失败,因为以下 SET 选项设置不正确:“ANSI_WARNINGS”。请验证 SET 选项是否正确用于索引视图和/或计算列上的索引和/或筛选索引和/或查询通知和/或 XML 数据类型方法和/或空间索引操作。
”
关于如何解决此问题有什么想法吗?
Using SQL Server 2008 (R2).
I have two tables in different databases (with same # of columns and datatypes - but different sizes)
. I'm inserting values from one to another, - but the problem is that the source table has say: nvarchar(200) and the destination table has a field of type nvarhchar(100).
And there is data in the source table with larger fields than 100 characters, so the error:
*String or binary data would be truncated is thrown.*
I tried using the
-- SourceServer is passed in at command prompt (batch)
SET ANSI_WARNINGS OFF
GO
INSERT INTO DestinationTable(col1, col2,...)
SELECT col1, col2, ...
FROM $SourceServer.dbo.SourceTable
SET ANSI_WARNINGS ON
GO
This is however, throwing an error which looks like this:
"INSERT failed because the following SET options have incorrect settings: 'ANSI_WARNINGS'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.
"
Any ideas on how I can fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以自己截断数据:
You could truncate the data yourself: