May 16, 2012

sp_MShelplogreader_agent (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_MShelplogreader_agent(nvarchar @publisher
, nvarchar @publisher_db)

MetaData:

 --   
-- Name:
-- sp_MShelplogreader_agent
--
-- Description:
-- Displays the following information on logreader agent:
-- LA id
-- name
-- publisher_security_mode
-- publisher_login
-- publisher_password
-- job_id
-- job_login
-- job_password
--
-- Security:
-- SA
-- Requires Certificate signature for catalog access
--
-- Returns:
-- 0 : success
-- 1 : failure
--

CREATE PROCEDURE sys.sp_MShelplogreader_agent
(
@publisher sysname,
@publisher_db sysname
)
AS
BEGIN
DECLARE @publisher_id int

-- Security Check: require sysadmin
IF (ISNULL(IS_SRVROLEMEMBER('sysadmin'),0) = 0)
BEGIN
RAISERROR(21089,16,-1)
RETURN 1
END

-- database must be distribution db
IF sys.fn_MSrepl_isdistdb(DB_NAME()) <> 1
BEGIN
RAISERROR (21482, 16, -1, 'sp_MShelplogreader_agent', 'distribution')
RETURN (1)
END

SELECT @publisher_id = server_id
FROM sys.servers
WHERE UPPER(name) = UPPER(@publisher)

SELECT msla.id,
msla.name,
msla.publisher_security_mode,
msla.publisher_login,
N'-- -- -- -- -- ' as [publisher_password],
sjb.job_id,
sc.credential_identity as [job_login],
N'-- -- -- -- -- ' as [job_password]
FROM MSlogreader_agents msla
JOIN msdb..sysjobs sjb
ON convert(uniqueidentifier, msla.job_id) = sjb.job_id
LEFT JOIN msdb..sysjobsteps sj
ON msla.job_step_uid = sj.step_uid
LEFT JOIN msdb..sysproxies sp
ON sj.proxy_id = sp.proxy_id
LEFT JOIN sys.credentials sc
ON sp.credential_id = sc.credential_id
WHERE msla.publisher_id = @publisher_id
AND msla.publisher_db = @publisher_db

RETURN 0
END

No comments:

Post a Comment

Total Pageviews