If a stored procedure or view depends on a table that has been dropped,sysdepends will continue referencing the old ID of the table as adependent, even if this ID does not exist any more. As a result,sp_dependswill not show the correct object dependency.
Drop and recreate the stored procedure or view. The entries for sysdependswill be properly recreated.
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
The following is an example of the problem. First, create the table andprocedure referencing that table.
create table testx (c int) go create procedure procx as select * from testx go select name, id from sysobjects where (name = "testx") or (name = "procx") go
name id ----------------------------- ---------- testx 464004684 procx 480004741
Now drop the table, and recreate it using the same name. Then new objectid.
drop table testx go create table testx (c int) go select id from sysobjects where name = "testx"
id ----------- 512004855
A query against sysdepends shows that the dependent object id is notupdated.
select id, depid from sysdepends where id = 480004741
id depid ---------- ---------- 480004741 464004684
Microsoft SQL Server 4.21a Standard Edition, Microsoft SQL Server 6.0 Standard Edition, Microsoft SQL Server 6.5 Standard Edition, Microsoft SQL Server 7.0 Standard Edition, Microsoft SQL Server 2000 Standard Edition