Create Table rs
(
Id int IDENTITY (1,1) Primary Key,
mId int Not NUll,
ad varchar Not NUll,
stvarchar Not NUll,
et varchar Not NUll,
nt varchar(max)
);
insert into rs ( nt, et, st, ad, mId)
values ('as','as','as','as',12)
我收到这个错误
Msg 8152, Level 16, State 14, Line 2
String or binary data would be truncated.
The statement has been terminated.
很简单的sql,但是解析起来有点困难
最佳答案
您没有为您的 varchar
变量设置大小,因此大小将默认为 1,因此在将大小为 2 的 varchar
插入表中时会出现此错误,为您的 varchar
变量提供大小以解决此问题
Create Table rs
(
Id int IDENTITY (1,1) Primary Key,
mId int Not NUll,
ad varchar(10) Not NUll,
st varchar(10) Not NUll,
et varchar(10) Not NUll,
nt varchar(max)
);
关于sql - 字符串或二进制数据将被截断。该语句已终止。简单错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37989013/