简体   繁体   English

sql 服务器数据库收缩命令出错

[英]Error on sql server database shrink command

I'm executing these commands from a Console Application我正在从控制台应用程序执行这些命令

DBCC SHRINKFILE (@FILE_NAME_MDF, 0) WITH NO_INFOMSGS
DBCC SHRINKFILE (@FILE_NAME_LDF, 0) WITH NO_INFOMSGS

and getting this error并得到这个错误

Could not shrink the XXX database Cannot create a row of size 8126 which is greater than the allowable maximum row size of 8060. The statement has been terminated.无法收缩 XXX 数据库 无法创建大小为 8126 的行,该行大于允许的最大行大小 8060。语句已终止。 System.Data.SqlClient.SqlException (0x80131904): Cannot create a row of size 812 6 which is greater than the allowable maximum row size of 8060. System.Data.SqlClient.SqlException (0x80131904):无法创建大小为 812 6 的行,该行大于允许的最大行大小 8060。

Any help would be greatly appreciated.任何帮助将不胜感激。

It sounds like your issue here is that a row in your database is near the edge of the maximum allowable size and when the DBCC SHRINKFILE is run, it adds more data to this row and pushes it over the limit.听起来您的问题是您的数据库中的一行接近最大允许大小的边缘,并且当 DBCC SHRINKFILE 运行时,它会向该行添加更多数据并将其推过限制。 I would look at your tables to see if there is one that is exceeding the size limits and see if you can't change it to store some data off-row.我会查看您的表格,看看是否有一个超出大小限制的表格,看看您是否无法更改它以在行外存储一些数据。 For example, if you have a very large nvarchar field, you could change it to TEXT which will allow you to store that data in its own page.例如,如果您有一个非常大的 nvarchar 字段,您可以将其更改为 TEXT,这将允许您将该数据存储在它自己的页面中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM