May 8, 2012

sp_MScheck_agent_instance (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_MScheck_agent_instance(nvarchar @application_name
, int @agent_type)

MetaData:

 create procedure sys.sp_MScheck_agent_instance  
@application_name sysname,
@agent_type int = NULL
as
declare @count_pro int
set nocount on

select @count_pro = count(*)
from sys.dm_exec_sessions
where program_name = @application_name collate database_default

-- type 3 is for 7.0 distribution agent backward compatibility.
if @agent_type = 3
begin
-- The distribution agent will before connecting to the publisher with unique
-- application name
if @count_pro > 0
raiserror (21036, 16, -1, 'distribution')
end
-- 10 is 7.5 version of the distribution agent.
else if @agent_type = 10
begin
-- The distribution agent will connecting to the publisher with unique
-- application name and then check.
if @count_pro > 1
raiserror (21036, 16, -1, 'distribution')
end
else if @agent_type = 4
begin
-- The merge agent will connect to the publisher with unique application name
-- then call this procedure
if @count_pro > 1
raiserror (21036, 16, -1, 'merge')
end
else if @agent_type = 1
begin
-- The snapshot agent will connect to the distributiondb with unique application name
-- then call this procedure
if @count_pro > 2
raiserror (21036, 16, -1, 'snapshot')
end
else if @agent_type = 2
begin
-- The logreader agent will connect to the distributiondb with unique application name
-- then call this procedure
if @count_pro > 1
raiserror (21036, 16, -1, 'logreader')
end
else if @agent_type = 9
begin
-- The queuereader agent will connect to the distributiondb with unique application name
-- then call this procedure
if @count_pro > 1
raiserror (21036, 16, -1, 'queuereader')
end

No comments:

Post a Comment

Total Pageviews