无法创建大小为 8081 的行,该行大于允许的最大行大小 8060
Cannot create a row of size 8081 which is greater than the allowable maximum row size of 8060
我检查了每个 link 的 Whosebug(我 Rebuild table too)和其他 link,但没有运气。
我必须分析一个应用程序。所以我通过特定路径上的应用程序实用程序获得了备份文件。我在 Sqlserver 2014 full version
中正确恢复了备份文件。然后我将应用程序的配置文件更改为这个sqlserver。
之后,当运行申请并通过申请提交员工表格时,会出现上述错误。
员工 table 数据库结构如下,它包含 47 列,没有任何行(这是第一个条目)。
CREATE TABLE [dbo].[employee](
[wcsuid] [nchar](30) NULL,
[lastupdatedate] [nchar](8) NULL,
[updatedatetime] [varchar](17) NULL,
[locationid] [nchar](20) NULL,
[isactive] [nchar](1) NULL,
[CreatedDate] [varchar](10) NULL,
[sdate] [nchar](90) NULL,
[identityemployeeno] [nchar](45) NULL,
[employeeid] [nchar](180) NULL,
[firstname] [nchar](120) NULL,
[lastname] [nchar](120) NULL,
[ssn] [nchar](99) NULL,
[dob] [nchar](90) NULL,
[gender] [nchar](9) NULL,
[address] [nchar](180) NULL,
[addressLine2] [nchar](180) NULL,
[city] [nchar](105) NULL,
[state] [nchar](180) NULL,
[zipcode] [nchar](135) NULL,
[isinternationaladdress] [nchar](9) NULL,
[telephone] [nchar](126) NULL,
[cellphone] [nchar](126) NULL,
[IdentityJobTitleNo] [nchar](45) NULL,
[manager] [nchar](120) NULL,
[hiredate] [nchar](90) NULL,
[terminationdate] [nchar](90) NULL,
[username] [nchar](90) NULL,
[userpassword] [nchar](90) NULL,
[userpassword_required] [nchar](9) NULL,
[employeestanding] [nchar](180) NULL,
[identityroleid] [nchar](45) NULL,
[loggedin] [nchar](9) NULL,
[punchedin] [nchar](9) NULL,
[punchedinTime] [nchar](90) NULL,
[punchedinDate] [nchar](90) NULL,
[contactname] [nchar](120) NULL,
[contactaddress] [nchar](180) NULL,
[contactaddressLine2] [nchar](180) NULL,
[contactcity] [nchar](105) NULL,
[contactstate] [nchar](30) NULL,
[contactzipcode] [nchar](135) NULL,
[isinternationalcontactaddress] [nchar](9) NULL,
[contactphone] [nchar](126) NULL,
[contactcellphone] [nchar](126) NULL,
[relationtoemployee] [nchar](180) NULL,
[worksoncommission] [nchar](9) NULL,
[overrideitemcommission] [nchar](9) NULL
) ON [PRIMARY]
并且插入语句(也有 47 个值)错误也显示在应用程序中,如下所示:
INSERT INTO employee
(
wcsuid,lastupdatedate,updatedatetime,locationid,isactive,CreatedDate,sdate,identityemployeeno,employeeid,firstname,lastname,ssn,dob,gender,address,addressLine2,city,state,zipcode,isinternationaladdress,telephone,cellphone,IdentityJobTitleNo,manager,hiredate,terminationdate,username,
userpassword,userpassword_required,employeestanding,identityroleid,loggedin,punchedin,punchedinTime,punchedinDate,contactname,contactaddress,contactaddressLine2,contactcity,contactstate,contactzipcode,isinternationalcontactaddress,contactphone,contactcellphone,relationtoemployee,worksoncommission,overrideitemcommission)
VALUES
(
'2015121512201580210002','','20151215122015802','','','20151215','','4','','Ajayendra','Raghuvanshi','','19782707','M','','','','','','','0792762063','','','','00000000','00000000','ajayendra',
'SdYHcqaxf1gMjjSkjmpUiw==','N','','','','','','','','','','','','','','','','','N','N')
是字符字段的限制,但我用值检查了所有长度,没有得到任何错误背后的逻辑。
所以问题是如何解决错误以及为什么会出现错误?
我不是 SQL 服务器专家,但是...添加上面的所有字段长度我得到 4,046
(我可能犯了一些错误 - 现在还为时过早,我仍然在第一杯咖啡...)。现在看 the manual:
nchar [ ( n ) ]
Fixed-length Unicode string data. n defines the string length and must be a value from 1 through 4,000. The storage size is two times n bytes. When the collation code page uses double-byte characters, the storage size is still n bytes. Depending on the string, the storage size of n bytes can be less than the value specified for n. The ISO synonyms for nchar are national char and national character..
请注意,存储每个字符需要两个字节。做 2 * 4046
我们有 8092
字节的行长度!另请注意 nchar
是 固定长度 我假设它是在创建 entry/row 时分配的,因此它会生成您看到的错误,告诉您该行太长。我希望它至少在您创建 table...
时警告您
解决方案
规范化更多:将 table 分成两部分,例如有一个 emploeeyAddress
table 如果您以后需要家庭和工作地址,这可能有意义每个员工
使用可变或动态长度的nvarchar
。存储仍然是每个字符 2 个字节,但仅用于插入的数据(未预先分配)。如果您尝试将所有字段填充到它们的最大长度,您将达到相同的限制
对于 nchar 值,每个字符占用两个字节,因此您应该将字符数乘以二以获得总行大小。
终于找到解决办法了。我在分析阶段,所以我不能改变规范化table。
阅读下面的内容后 link,我明白了这个问题。所以我只是重新创建了一个 "Employee" table 和 nvarchar
数据类型,因为我只有一个选择。
感谢@urban 给出正确的方向,为此我接受他的回答。
What is the difference between char, nchar, varchar, and nvarchar in SQL Server?
我检查了每个 link 的 Whosebug(我 Rebuild table too)和其他 link,但没有运气。
我必须分析一个应用程序。所以我通过特定路径上的应用程序实用程序获得了备份文件。我在 Sqlserver 2014 full version
中正确恢复了备份文件。然后我将应用程序的配置文件更改为这个sqlserver。
之后,当运行申请并通过申请提交员工表格时,会出现上述错误。
员工 table 数据库结构如下,它包含 47 列,没有任何行(这是第一个条目)。
CREATE TABLE [dbo].[employee](
[wcsuid] [nchar](30) NULL,
[lastupdatedate] [nchar](8) NULL,
[updatedatetime] [varchar](17) NULL,
[locationid] [nchar](20) NULL,
[isactive] [nchar](1) NULL,
[CreatedDate] [varchar](10) NULL,
[sdate] [nchar](90) NULL,
[identityemployeeno] [nchar](45) NULL,
[employeeid] [nchar](180) NULL,
[firstname] [nchar](120) NULL,
[lastname] [nchar](120) NULL,
[ssn] [nchar](99) NULL,
[dob] [nchar](90) NULL,
[gender] [nchar](9) NULL,
[address] [nchar](180) NULL,
[addressLine2] [nchar](180) NULL,
[city] [nchar](105) NULL,
[state] [nchar](180) NULL,
[zipcode] [nchar](135) NULL,
[isinternationaladdress] [nchar](9) NULL,
[telephone] [nchar](126) NULL,
[cellphone] [nchar](126) NULL,
[IdentityJobTitleNo] [nchar](45) NULL,
[manager] [nchar](120) NULL,
[hiredate] [nchar](90) NULL,
[terminationdate] [nchar](90) NULL,
[username] [nchar](90) NULL,
[userpassword] [nchar](90) NULL,
[userpassword_required] [nchar](9) NULL,
[employeestanding] [nchar](180) NULL,
[identityroleid] [nchar](45) NULL,
[loggedin] [nchar](9) NULL,
[punchedin] [nchar](9) NULL,
[punchedinTime] [nchar](90) NULL,
[punchedinDate] [nchar](90) NULL,
[contactname] [nchar](120) NULL,
[contactaddress] [nchar](180) NULL,
[contactaddressLine2] [nchar](180) NULL,
[contactcity] [nchar](105) NULL,
[contactstate] [nchar](30) NULL,
[contactzipcode] [nchar](135) NULL,
[isinternationalcontactaddress] [nchar](9) NULL,
[contactphone] [nchar](126) NULL,
[contactcellphone] [nchar](126) NULL,
[relationtoemployee] [nchar](180) NULL,
[worksoncommission] [nchar](9) NULL,
[overrideitemcommission] [nchar](9) NULL
) ON [PRIMARY]
并且插入语句(也有 47 个值)错误也显示在应用程序中,如下所示:
INSERT INTO employee
(
wcsuid,lastupdatedate,updatedatetime,locationid,isactive,CreatedDate,sdate,identityemployeeno,employeeid,firstname,lastname,ssn,dob,gender,address,addressLine2,city,state,zipcode,isinternationaladdress,telephone,cellphone,IdentityJobTitleNo,manager,hiredate,terminationdate,username,
userpassword,userpassword_required,employeestanding,identityroleid,loggedin,punchedin,punchedinTime,punchedinDate,contactname,contactaddress,contactaddressLine2,contactcity,contactstate,contactzipcode,isinternationalcontactaddress,contactphone,contactcellphone,relationtoemployee,worksoncommission,overrideitemcommission)
VALUES
(
'2015121512201580210002','','20151215122015802','','','20151215','','4','','Ajayendra','Raghuvanshi','','19782707','M','','','','','','','0792762063','','','','00000000','00000000','ajayendra',
'SdYHcqaxf1gMjjSkjmpUiw==','N','','','','','','','','','','','','','','','','','N','N')
是字符字段的限制,但我用值检查了所有长度,没有得到任何错误背后的逻辑。
所以问题是如何解决错误以及为什么会出现错误?
我不是 SQL 服务器专家,但是...添加上面的所有字段长度我得到 4,046
(我可能犯了一些错误 - 现在还为时过早,我仍然在第一杯咖啡...)。现在看 the manual:
nchar [ ( n ) ] Fixed-length Unicode string data. n defines the string length and must be a value from 1 through 4,000. The storage size is two times n bytes. When the collation code page uses double-byte characters, the storage size is still n bytes. Depending on the string, the storage size of n bytes can be less than the value specified for n. The ISO synonyms for nchar are national char and national character..
请注意,存储每个字符需要两个字节。做 2 * 4046
我们有 8092
字节的行长度!另请注意 nchar
是 固定长度 我假设它是在创建 entry/row 时分配的,因此它会生成您看到的错误,告诉您该行太长。我希望它至少在您创建 table...
解决方案
规范化更多:将 table 分成两部分,例如有一个
emploeeyAddress
table 如果您以后需要家庭和工作地址,这可能有意义每个员工使用可变或动态长度的
nvarchar
。存储仍然是每个字符 2 个字节,但仅用于插入的数据(未预先分配)。如果您尝试将所有字段填充到它们的最大长度,您将达到相同的限制
对于 nchar 值,每个字符占用两个字节,因此您应该将字符数乘以二以获得总行大小。
终于找到解决办法了。我在分析阶段,所以我不能改变规范化table。
阅读下面的内容后 link,我明白了这个问题。所以我只是重新创建了一个 "Employee" table 和 nvarchar
数据类型,因为我只有一个选择。
感谢@urban 给出正确的方向,为此我接受他的回答。
What is the difference between char, nchar, varchar, and nvarchar in SQL Server?