尽管数据看似合适,但在插入时“字符串或二进制数据将被截断”

时间:2016-09-15 13:25:22

标签: sql sql-server sql-server-2014

我有一张这样的桌子:

CREATE TABLE Customers
(CustomerID int Identity (1,1) NOT NULL PRIMARY KEY,
customerName varchar (50),
Address varchar (255),
Phone int NOT NULL,
Email varchar,
Gender varchar,
Age int, 
);

我尝试像这样插入这个表:

Insert into Customers (customerName, Address, Phones, Email, Gender, Age)
Values ('Anosa Seunge', 'Keskuskatu 200', 358-3-4180, 'ijiosd@ao.com', 'Male', 19),
        ('Jihad Christian', '305 - 14th Ave. Suite 3B', 358-1-3688, 'jihado@ao.com', 'Female', 29);

并收到此错误:

Msg 8152, Level 16, State 14, Line 4
String or binary data would be truncated.
The statement has been terminated.

1 个答案:

答案 0 :(得分:5)

您的EmailGender字段的长度为1,这可能是Gender的所需内容(尽管可能不是基于您的插入语句),但肯定不是{ {1}}。

你想要这样的东西:

Email