May 15, 2012

sp_MSgetagentoffloadinfo (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_MSgetagentoffloadinfo(varbinary @job_id)

MetaData:

 CREATE PROCEDURE sys.sp_MSgetagentoffloadinfo   
(
@job_id VARBINARY(16)
)
AS
begin
SET NOCOUNT ON
DECLARE @agenttype NVARCHAR(20)
DECLARE @offload_enabled bit
DECLARE @offload_server sysname
DECLARE @agent_table sysname -- For use in error message
DECLARE @independent_agent bit

--
-- security check
-- only db_owner can execute this
--
if (is_member ('db_owner') != 1)
begin
raiserror(14260, 16, -1)
return (1)
end

SELECT @agenttype = NULL
SELECT @agent_table = RTRIM(@@SERVERNAME) + N'.dbo.'
SELECT @independent_agent = 0

SELECT @agenttype = LOWER(subsystem collate SQL_Latin1_General_CP1_CS_AS)
FROM msdb.dbo.sysjobsteps
WHERE job_id = @job_id
AND LOWER(subsystem collate SQL_Latin1_General_CP1_CS_AS) IN (N'distribution', N'merge')

IF @agenttype IS NULL
BEGIN
RAISERROR(21134, 16, -1)
RETURN 1
END

IF @agenttype = N'distribution'
BEGIN
SELECT @offload_enabled = offload_enabled,
@offload_server = offload_server
FROM dbo.MSdistribution_agents da
INNER JOIN dbo.MSsubscriptions s
ON da.id = s.agent_id
WHERE job_id = @job_id
SELECT @agent_table = @agent_table + N'MSdistribution_agents'
END
ELSE
BEGIN
SELECT @offload_enabled = offload_enabled,
@offload_server = offload_server
FROM dbo.MSmerge_agents
WHERE job_id = @job_id
SELECT @agent_table = @agent_table + N'MSmerge_agents'
END

IF @@ROWCOUNT = 0
BEGIN
RAISERROR(21135, 16, -1, @agent_table)
RETURN 1
END

IF @agenttype = N'distribution'
BEGIN
SELECT 'offload_enabled' = @offload_enabled,
'offload_server' = @offload_server,
'independent_agent' = @independent_agent
END
ELSE
BEGIN
SELECT 'offload_enabled' = @offload_enabled,
'offload_server' = @offload_server
END

RETURN 0
end

No comments:

Post a Comment

Total Pageviews