一个一分钟执行次数达到几十万的存储过程,但是编译不通过
时间:2011-12-06
来源:互联网
create procedure sys.sp_MSinit_replication_perfmon
as
begin
declare @return_code int,
@agent_type int,
@agent_name nvarchar(100),
@status int,
@all_but_misc_agents int
select @all_but_misc_agents = -1
-- drop the temp table
if object_id('tempdb.dbo.#tmp_replication_status') is not null
begin
drop table #tmp_replication_status
end
-- create the temp table
create table #tmp_replication_status
(
publisher sysname,
publisher_db sysname,
publication sysname,
publication_type int,
agent_type int,
status int,
agent_id int,
agent_name sysname,
job_id uniqueidentifier null,
time_stamp datetime null,
publisher_srvid int null
)
create clustered index ctmpreplicationstatus on #tmp_replication_status (publication, publisher_db, publisher)
create index nc1tmpreplicationstatus on #tmp_replication_status (publisher, publisher_db)
create index nc2tmpreplicationstatus on #tmp_replication_status (agent_type)
-- Remove all existing instances
dbcc deleteinstance ("SQL Replication Agents", "%")
dbcc deleteinstance ("SQL Replication Snapshot", "%")
dbcc deleteinstance ("SQL Replication Logreader", "%")
dbcc deleteinstance ("SQL Replication Distribution", "%")
dbcc deleteinstance ("SQL Replication Merge", "%")
dbcc deleteinstance ("SQL Replication Queuereader", "%")
-- Add and initialize Perfmon SQL Replication Agents instances
dbcc addinstance ("SQL Replication Agents", "Snapshot")
dbcc addinstance ("SQL Replication Agents", "Logreader")
dbcc addinstance ("SQL Replication Agents", "Distribution")
dbcc addinstance ("SQL Replication Agents", "Merge")
dbcc addinstance ("SQL Replication Agents", "Queuereader")
dbcc setinstance ("SQL Replication Agents", "Running", "Snapshot", 0)
dbcc setinstance ("SQL Replication Agents", "Running", "Logreader", 0)
dbcc setinstance ("SQL Replication Agents", "Running", "Distribution", 0)
dbcc setinstance ("SQL Replication Agents", "Running", "Merge", 0)
dbcc setinstance ("SQL Replication Agents", "Running", "Queuereader", 0)
-- load tmp replication_status table
exec @return_code = sys.sp_MSload_tmp_replication_status @agent_type = @all_but_misc_agents
if @@error <> 0 or @return_code <> 0
return 1
-- Add instances for each agent currently in the status table
declare hC CURSOR LOCAL FAST_FORWARD for
select agent_type,
agent_name,
status
from #tmp_replication_status for read only
open hC
fetch hC into @agent_type, @agent_name, @status
大家可以编译一下,这个语句根本编译不通过,但是还一直执行,求高手指点!!!!!
作者: blue_hao 发布时间: 2011-12-06
作者: fredrickhu 发布时间: 2011-12-06
作者: blue_hao 发布时间: 2011-12-06
作者: ssp2009 发布时间: 2011-12-06
作者: blue_hao 发布时间: 2011-12-06
存储过程的最后少了这2句,
SQL code
close hC deallocate hC
作者: ap0405140 发布时间: 2011-12-06
你怎么获取这些语句的,获取方法引起被截取
作者: Haiwer 发布时间: 2011-12-06
语句是不全 但是为什么还会执行呢
作者: blue_hao 发布时间: 2011-12-06
作者: qqyatou 发布时间: 2011-12-06
那个有用到这个存储过程的视图或者其他什么的,你要重新编译一下.
不重新编译,他还是会用以前的编译好的
如果不是:
请在仔细找下原因吧

作者: qqyatou 发布时间: 2011-12-06
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28