本文介绍了SQL Server 错误:字符串或二进制数据将被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的桌子:
log_id bigint
old_value xml
new_value xml
module varchar(50)
reference_id bigint
[transaction] varchar(100)
transaction_status varchar(10)
stack_trace ntext
modified_on datetime
modified_by bigint
插入查询:
INSERT INTO [dbo].[audit_log]
([old_value],[new_value],[module],[reference_id],[transaction]
,[transaction_status],[stack_trace],[modified_on],[modified_by])
VALUES
('asdf','asdf','Subscriber',4,'_transaction',
'_transaction_status','_stack_trace',getdate(),555)
错误:
Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.
这是为什么???
推荐答案
您正在尝试写入超过特定列可以存储的更多数据.根据每个字段的大小检查您尝试插入的数据的大小.
You're trying to write more data than a specific column can store. Check the sizes of the data you're trying to insert against the sizes of each of the fields.
在这种情况下,transaction_status 是一个 varchar(10) 并且您试图向它存储 19 个字符.
In this case transaction_status is a varchar(10) and you're trying to store 19 characters to it.
这篇关于SQL Server 错误:字符串或二进制数据将被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!