I have this table:
我有这个表:
CREATE TABLE Vendors
(
VendorID NUMERIC(10) NOT NULL,
VendorName CHAR(50) NOT NULL,
VendorAddress VARCHAR(30) NULL,
VendorCityName VARCHAR(20) NOT NULL,
VendorStateName CHAR(2) NOT NULL,
VendorZip VARCHAR(10) NULL,
VendorContactName CHAR(50) NOT NULL,
VendorContactPhone VARCHAR(12) NOT NULL,
VendorContactEmail VARCHAR(20) NOT NULL,
VendorSpecialty CHAR(20) NOT NULL
CONSTRAINT VendorsPK PRIMARY KEY (VendorID)
);
And this insert:
这插入:
INSERT INTO Vendors(VendorID, VendorName, VendorAddress,
VendorCityName, VendorStateName, VendorZip, VendorContactName,
VendorContactPhone, VendorContactEmail, VendorSpecialty)
VALUES(151330, 'Hyperion', '77 West 66th Street', 'New York',
'NY', 10023, 'John Hinks', '212-337-6564',
'jhinks@hyperionbooks.com', 'Popular fiction')
Why does this statement yield the 8152 error?
为什么这个语句会产生8152错误?
2 个解决方案
#1
23
VendorContactEmail
is only 20 bytes. Your e-mail address on the first line (jhinks@hyperionbooks.com
) is longer than that - 24 bytes. And many e-mail addresses will be longer. Who decided to only allow 20 characters in the e-mail address column? According to the standard, this should be VARCHAR(320)
- 64 characters for localpart + 1 for @ + 255 for domain.
VendorContactEmail只有20字节。第一行的电子邮件地址(jhinks@hyperionbooks.com)要比第一行长24字节。而且许多电子邮件地址将会更长。谁决定在电子邮件地址栏中只允许20个字符?根据标准,这应该是VARCHAR(320) - 64个字符为localpart + 1为@ + 255为域。
#2
5
Force Operation that Results in Truncation to Execute Anyway
强制执行导致截断的操作
SET ANSI_WARNINGS OFF;
-- Your operation TSQL here.
SET ANSI_WARNINGS ON;
(源)
#1
23
VendorContactEmail
is only 20 bytes. Your e-mail address on the first line (jhinks@hyperionbooks.com
) is longer than that - 24 bytes. And many e-mail addresses will be longer. Who decided to only allow 20 characters in the e-mail address column? According to the standard, this should be VARCHAR(320)
- 64 characters for localpart + 1 for @ + 255 for domain.
VendorContactEmail只有20字节。第一行的电子邮件地址(jhinks@hyperionbooks.com)要比第一行长24字节。而且许多电子邮件地址将会更长。谁决定在电子邮件地址栏中只允许20个字符?根据标准,这应该是VARCHAR(320) - 64个字符为localpart + 1为@ + 255为域。
#2
5
Force Operation that Results in Truncation to Execute Anyway
强制执行导致截断的操作
SET ANSI_WARNINGS OFF;
-- Your operation TSQL here.
SET ANSI_WARNINGS ON;
(源)