事实是如果你不问,你就不敢确定到底是不是必须挨个打开来看 请楼主尊重每个热心回答你问题的人--下面的这个方法也只能检查一下其他的视图是否包含'V_StockInfo' ,如果包含了 'V_StockInfo_1'这种字符串,那也会被查询出来,所以还是需要在结果里的视图挨个打开验证。select identity(int,1,1) as id,name,0 as flag into #vlist from sysobjects where xtype = 'v' create table #t ( context nvarchar(max) )declare @i int,@count int declare @oname nvarchar(200) select @oname = '' select @i = 1 select @count = count(1) from #vlistwhile (@i <= @count) begin select @oname = name from #vlist where id = @i insert into #t(context) exec sp_helptext @objname = @oname if exists(select 1 from #t where context like '%V_StockInfo%') update #vlist set flag = 1 where id = @i select @i = @i + 1 end select name from #vlist where flag = 1drop table #vlist drop table #t
请楼主尊重每个热心回答你问题的人--下面的这个方法也只能检查一下其他的视图是否包含'V_StockInfo' ,如果包含了 'V_StockInfo_1'这种字符串,那也会被查询出来,所以还是需要在结果里的视图挨个打开验证。select identity(int,1,1) as id,name,0 as flag into #vlist from sysobjects where xtype = 'v'
create table #t
(
context nvarchar(max)
)declare @i int,@count int
declare @oname nvarchar(200)
select @oname = ''
select @i = 1
select @count = count(1) from #vlistwhile (@i <= @count)
begin
select @oname = name from #vlist where id = @i insert into #t(context)
exec sp_helptext @objname = @oname if exists(select 1 from #t where context like '%V_StockInfo%')
update #vlist set flag = 1 where id = @i select @i = @i + 1
end
select name from #vlist where flag = 1drop table #vlist
drop table #t