Inner
(1)
Exec
(1)
CurrentJobName
(1)
Database
(1)
Distribution.dbo.MSlogreader
(1)
Distribution.dbo.MSsnapshot
(1)
CurrentName
(1)
OldName
(1)

Howto find the Name of Logreader and Distribution Task

Asked By Thomas Hase
20-Nov-09 09:37 AM
Hi NG,

MSSQL2k8 Transactional Replication

How can I find with T-SQL for a known publication
the name or ID of the related task for logreader-task, snapshot-task
and distribution task, if the task was manually renamed.

Thanks in advanced.

Thomas

Hi Thomas,here are the queries you need:distribution agents (assuming

Paul Ibison replied to Thomas Hase
22-Nov-09 07:37 AM
Hi Thomas,

here are the queries you need:

distribution agents (assuming push):

select a.job_id, a.name as OldName, b.name as CurrentName
from distribution.dbo.MSdistribution_agents a
inner join msdb.dbo.sysjobs b
on a.job_id = b.job_id

log reader agents:

select a.job_id, a.name as OldName, b.name as CurrentName
from distribution.dbo.MSlogreader_agents a
inner join msdb.dbo.sysjobs b
on a.job_id = b.job_id

snapshot agents:

select a.job_id, a.name as OldName, b.name as CurrentName
from distribution.dbo.MSsnapshot_agents a
inner join msdb.dbo.sysjobs b
on a.job_id = b.job_id

HTH,

Paul Ibison

Hallo Paul,thanks it works, but my question was wrong.

Thomas Hase replied to Paul Ibison
23-Nov-09 01:00 PM
Hallo Paul,

thanks it works, but my question was wrong.

On the MSSQL are many (10) publications.

Pub01
Pub02
..
Pub10


An I want to find VIA the name of publication all
related jobs.


exec sp_show_me_all_related_jobs 'pubName'

I am looking for a way to find out

Thomas

You can adapt my queries using a union statement as follows:select a.

Paul Ibison replied to Thomas Hase
23-Nov-09 01:30 PM
You can adapt my queries using a union statement as follows:

select a.* from
(
select a.publication, b.name as CurrentJobName
from distribution.dbo.MSdistribution_agents a
inner join msdb.dbo.sysjobs b
on a.job_id = b.job_id
union
select a.publication, b.name as CurrentJobName
from distribution.dbo.MSlogreader_agents a
inner join msdb.dbo.sysjobs b
on a.job_id = b.job_id
union
select a.publication, b.name as CurrentJobName
from distribution.dbo.MSsnapshot_agents a
inner join msdb.dbo.sysjobs b
on a.job_id = b.job_id
) a
where a.publication = 'yourpubname'

This works for transactional. If you need merge then let me know.

HTH,

Pual Ibison
Hallo Paul,thanks, I have not seen the collumn "publication".If I try:select A.
Thomas Hase replied to Paul Ibison
23-Nov-09 02:05 PM
Hallo Paul,

thanks, I have not seen the collumn "publication".


If I try:

select A.PUBLICATION, a.job_id, a.name as OldName, b.name as
CurrentName
from distribution.dbo.MSlogreader_agents a
inner join msdb.dbo.sysjobs b
on a.job_id = b.job_id

then I get in column: publication -> "ALL"  instead the name of the
publication


ALL	0x8E585BD4349ABC45B8DB66C8A540974A	ST-BB-SRV2-DB1-7 ..
ALL	0x9EF19737EBB26D45BAB1A3013CF3D09F	ST-BB-SRV2-DB2-6 ..


Is this a missconfig of my replication?

Thomas
Only applies to the log reader agent - they do not belong to a
Paul Ibison replied to Thomas Hase
23-Nov-09 02:17 PM
Only applies to the log reader agent - they do not belong to a particular
publication - just a transactionally replicated database.
The other ones will give the publication name.
HTH,
Paul Ibison
Hallo Paul,thank youThomas
Thomas Hase replied to Paul Ibison
24-Nov-09 10:26 AM
Hallo Paul,



thank you


Thomas
Post Question To EggHeadCafe