日期:2014-05-17 浏览次数:20490 次
create view dbo.view_tt
as
select *
from sysobjects
go
create view dbo.view_t1
as
select *
from dbo.view_tt
go
--查询依赖关系
select distinct OBJECT_NAME(id) ,
OBJECT_NAME(depid),
OBJECT_NAME(id) +'依赖'+OBJECT_NAME(depid)
from sysdepends
where id = OBJECT_ID('view_t1')
/*
view_t1 view_tt view_t1依赖view_tt
*/
--删除视图
drop view view_tt
--再次查询依赖关系
select distinct OBJECT_NAME(id) ,
OBJECT_NAME(depid),
OBJECT_NAME(id) +'依赖'+OBJECT_NAME(depid)
from sysdepends
where id = OBJECT_ID('view_t1')
/*
*/
--直接报错
select *
from dbo.view_t1
/*
消息 208,级别 16,状态 1,过程 view_t1,第 5 行
对象名 'dbo.view_tt' 无效。
消息 4413,级别 16,状态 1,第 2 行
由于绑定错误,无法使用视图或函数 'dbo.view_t1'。
*/