执行查询DBCC CHECKDB WITH NO_INFOMSGS
失败,并显示以下错误:
Page(1:2772455),对象ID 689489585中的插槽8,索引ID 1, 分区ID 72057594305052672,分配单元ID 72057594619953152(类型 “行内数据”)。列“日期”值超出数据类型的范围 “日期时间”。
将列更新为合法值。
我在为数据库的特定表运行DBCC checkDB
命令时收到了上述消息
当我尝试通过运行以下查询来获取该表的日期列时: -
select [date]
from [TableName]
where [Year] = 2011
and Month = 1
and [Date] < '1753-01-01'
and Date > '9999-12-31'
答案 0 :(得分:0)
您可以尝试使用Between
关键字,如下所示: -
select [date] from [TableName] where [Year]=2011 and Month=1 and [Date] between ('1753-01-01','9999-12-31')
答案 1 :(得分:0)
首先,您的WHERE clause
没有意义
[Year] = 2011
表示您只需要2011条记录,无需过滤
按日期范围。出于某种原因,如果您需要它应该是[date] BETWEEN '17530101' AND '99991231
建议使用ISO date format
yyyymmdd
(即;
'17530101'
)。 这可能是日期超出范围错误的原因。
我认为这将完成这项工作;
SELECT [date] FROM [TableName] WHERE [Year] = 2011 AND Month = 1
--AND [date] BETWEEN '17530101' AND '99991231'
--This filter does not make sense as you have already filtered by 2011.