我建议不要替换数据。 它没有问题, 只是 SSMs 无法在编辑面板 < / em> 中正确显示数据。 数据库本身的数据从您的描述来看是完全正常的 。
此脚本显示问题 :
create table test (id int not null identity(1,1) primary key,
large_value numeric(38,0));
go
insert into test (large_value) values (1);
insert into test (large_value) values (12345678901234567890123456789012345678);
insert into test (large_value) values (1234567890123456789012345678901234567);
insert into test (large_value) values (123456789012345678901234567890123456);
insert into test (large_value) values (12345678901234567890123456789012345);
insert into test (large_value) values (1234567890123456789012345678901234);
insert into test (large_value) values (123456789012345678901234567890123);
insert into test (large_value) values (12345678901234567890123456789012);
insert into test (large_value) values (1234567890123456789012345678901);
insert into test (large_value) values (123456789012345678901234567890);
insert into test (large_value) values (12345678901234567890123456789);
insert into test (large_value) values (NULL);
go
select * from test;
go
SELECT 工作将正常, 但是在对象探索器中显示 编辑前200行将不会 :
"https://i.sstatic.net/pw17P.png" alt="无法编辑Data"/ >
有",http://connect.microsoft.com/SQLServer/feedback/details/356/sms-edit-first-200-rows-sms-es-unable-unable-to-read-data-for-deminal-p-s-s-s-s-while-p-s-s-s-s-p-s-p-s-s-p-s-serf-times-timal-p-p-s-s-serl=“noreferrer”。2012 SSMS 2012 仍然存在同样的问题。
如果我们看", http://msdn.microsoft.com/en-us/library/aa258832%28v=sql.80%29.aspx" rel=“noreferr”>Numeric和Decimal 的细节,我们就会看到问题发生在一个奇特的边界,精确度为29,实际上是 not SQL服务器边界(精度28是):
Precision Storage bytes
1 - 9 5
10-19 9
20-28 13
29-38 17
如果我们检查了.Net (SSMS是一个管理式应用程序), < a href="http://msdn.microsoft.com/en-us/library/364x0z75.aspx" rel="noreferr" >十进制精确表 ,我们就能很快看到问题的关键所在是:精密度 < 坚固> 28-29 重要数字 。 因此, Net < code> decitimal 类型无法映射高精度( & gt;29) SQL 服务器 number
//decode > dectimal
类型。
这将不仅影响SSMS 显示, 而且还影响您的应用程序。 SISIS 等专门应用程序将使用高精度表示法, 如 < code> DT_ NUMERC < /code > :
DT_NUMERIC
An exact numeric value with a fixed precision and scale.
This data type is a 16-byte unsigned integer with a separate sign, a
scale of 0 - 38, and a maximum precision of 38.
现在回到问题: 您可以通过简单的查看值来发现无效的条目。 知道 C# 表示范围可以包含大约值( 7.9 x 10 < sup>28 sup > 到 7.9 x 10 < sup>28 sup > ) / ( 10 < sup> 0 到 28 sup > ) / (这个范围取决于比例) ` (这个范围取决于比例) 您可以在每列中搜索范围以外的值( 要在列中搜索的实际值取决于列的尺度)。 但这引出了用什么来取代数据的问题?
我建议使用专门的进出口工具,即能够处理高精度数字值的工具。SSIS是显而易见的候选者。但即使微小的bcp.exe 也符合该法案。
如果你的数值实际上不正确(如:真正的腐败),那么我建议运行 < a href="http://msdn.microsoft.com/en-us/library/ms174338.aspx" rel="noreferr"\\code>DBCC CHECKTable(.)与DATA_Purity 运行:
<强>DATA_实用 强>
Causes DBCC CHECKDB to check the database for column values that are not valid or out-of-range. For example, DBCC CHECKDB detects
columns with date and time values that are larger than or less than
the acceptable range for the datetime data type; or decimal or
approximate-numeric data type columns with scale or precision values
that are not valid.
For databases created in SQL Server 2005 and later, column-value integrity checks are enabled by default and do not require the
DATA_PURITY option. For databases upgraded from earlier versions of
SQL Server, column-value checks are not enabled by default until DBCC
CHECKDB WITH DATA_PURITY has been run error free on the database.
After this, DBCC CHECKDB checks column-value integrity by default.
问题: datetime
列中如何出现这个问题?
use tempdb;
go
create table test(d datetime)
insert into test (d) values (getdate())
select %%physloc%%, * from test;
-- Row is on page 0x9100000001000000
dbcc traceon(3604,-1);
dbcc page(2,1,145,3);
Memory Dump @0x000000003FA1A060
0000000000000000: 10000c00 75f9ff00 6aa00000 010000 ....uùÿ.j .....
Slot 0 Column 1 Offset 0x4 Length 8 Length (physical) 8
dbcc writepage(2,1,145, 100, 8, 0xFFFFFFFFFFFFFFFF)
"https://i.sstatic.net/YIYfe.png" alt="顶部200"/>
dbcc checktable( test ) with data_purity;
Msg 2570, Level 16, State 3, Line 2 Page (1:145), slot 0 in object ID
837578022, index ID 0, partition ID 2882303763115671552, alloc unit ID
2882303763120062464 (type "In-row data"). Column "d" value is out of
range for data type "datetime". Update column to a legal value.