我有一个名为
table1
的临时表,创建如下:
create table
tempdb..table1
(id int)
该表不是由
tempdb
数据库的所有者创建的。
当我早些时候尝试使用此查询访问表时,在存储过程中(仅用于测试):
select top 10 * from tempdb..table1
我收到此错误:
Msg 208, Level 16, State 1:
Server 'SERVER', Procedure 'storedProcedure', Line 30:
tempdb..table1 not found. Specify owner.objectname or use sp_help to check whether the object
exists (sp_help may produce lots of output).
但是,大约一个小时后,相同的存储过程运行时没有任何问题。
在那个小时内该表没有被删除并再次创建,我找不到这种奇怪行为的任何原因。我可以通过应用某种命名黑客来解决这个问题,但我不想将黑客插入到非常敏感的流程中,这意味着很多用户可以删除并创建表。
我问是否有人可以解释这种行为,以便我从现在开始可以避免这种行为。
使用tempdb.owner.tablename进行查询。可能是 tempdb.guest.table1