English 中文(简体)
如何通过储存程序落实数据库中的所有观点
原标题:How to execute all views in database through stored procedure

我们的表象与我们的表象相左。 我愿知道,我如何能够有一个储存程序(Sql服务器),在数据库中征求所有意见,并通过选择执行。

这就是我想象的(假想):


Declare x
Set x = Select object from sysobjects where object = view

foreach view in x
sp_execute select * from view


这样,我们就可以进行自动测试,每晚打一次。 SqlException公司表示,有些东西是 out。

最佳回答

应于2000年完成并更新

select quotename(table_schema) + .  + quotename(table_name) as ViewNAme,
 identity(int,1,1) as ID
  into #test
  from information_schema.tables
 where table_type =  view 


declare @Loopid int,@MaxID int


select @LoopID =1,@MaxID =MAX(id) 
from #test

declare @ViewName varchar(100)

while @LoopID <= @MaxID
begin

select @ViewName = ViewNAme 
from #test
where id = @LoopID

exec ( select top 1 * from   + @ViewName)
set @LoopID = @LoopID + 1
end

drop table #test

我主要集中在你提问的某一部分,也见。 如何通过使用间谍——refreshview确保这种观点具有根本性的表格变化

问题回答

2008年,你可以使用以下方法查明未解决的受抚养人,而无需实际选择。

SELECT * 
FROM sys.views v
JOIN sys.sql_expression_dependencies e ON e.referencing_id = v.object_id
and  referenced_id is null




相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签