+ -
当前位置:首页 → 问答吧 → sql中定义表变量失败,求援!

sql中定义表变量失败,求援!

时间:2011-11-26

来源:互联网


我想定义一个表变量,如下:
declare @a as table(c1 decimal(30,5))

sql给出错误提示:
SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:836629; actual 0:0). It occurred during a read of page (1:836629) in database ID 2 at offset 0x0000019882a000 in file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\tempdb.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

既然定义表变量失败,我想我就定义一个临时表吧,如下:
CREATE TABLE #a(c1 decimal(30,5))
还是同样的失败,同样的失败提示。

于是,我就DBCC CHECKDB一下吧,结论是:
CHECKDB found 0 allocation errors and 0 consistency errors in database 'model'.

没法了,sos!

作者: raylee1983   发布时间: 2011-11-26

SQL code
declare @a table(c1 decimal(30,5))

作者: roy_88   发布时间: 2011-11-26

去掉 as

作者: roy_88   发布时间: 2011-11-26

SQL code
declare @a  table(c1 decimal(30,5))

作者: roy_88   发布时间: 2011-11-26

tempdb error,run:

use master
go

dbcc checkdb('tempdb')

作者: NBDBA   发布时间: 2011-11-26

还是同样的错误提示啊。

我之前也是可以正常通过这条语句的,今天突然就不行了。

作者: raylee1983   发布时间: 2011-11-26

引用 4 楼 nbdba 的回复:
tempdb error,run:

use master
go

dbcc checkdb('tempdb')


运行的结果,怎么解决呢?

Msg 7985, Level 16, State 2, Line 1
System table pre-checks: Object ID 13. Could not read and latch page (1:836626) with latch type SH. Check statement terminated due to unrepairable error.
DBCC results for 'tempdb'.
Msg 5256, Level 16, State 1, Line 1
Table error: alloc unit ID 0, page (1:836626) contains an incorrect page ID in its page header. The PageId in the page header = (0:0).
CHECKDB found 0 allocation errors and 1 consistency errors not associated with any single object.
CHECKDB found 0 allocation errors and 1 consistency errors in database 'tempdb'.

作者: raylee1983   发布时间: 2011-11-26

重啟一下SQL服務,再試
每次启动 SQL Server 时都会重新创建 tempdb

作者: roy_88   发布时间: 2011-11-26

引用 5 楼 raylee1983 的回复:

还是同样的错误提示啊。

我之前也是可以正常通过这条语句的,今天突然就不行了。


临时表和表变量缓存在Tempdb,你重扈一下SQL服務試試,不行估計需要重建系統庫Model

作者: roy_88   发布时间: 2011-11-26

引用 8 楼 roy_88 的回复:
引用 5 楼 raylee1983 的回复:

还是同样的错误提示啊。

我之前也是可以正常通过这条语句的,今天突然就不行了。


临时表和表变量缓存在Tempdb,你重扈一下SQL服務試試,不行估計需要重建系統庫Model


解决了!
我在services.msc里面关闭所有和sql有关的服务,再重新启动一次,就可以了。
感谢中国风!

作者: raylee1983   发布时间: 2011-11-26

热门下载

更多