Groups | Blog | Home
all groups > sql server replication > january 2005 >

sql server replication : Replication Faliuer Status



Sharad
1/6/2005 5:10:56 AM
Dear Friends

Please suggest where i can get the status for the
replication ( Same is working or in failed status ). What
i want to do is when the user is taking the INVOICENUMBER
from the application it should check for the status of
the replication if the same is working or not.

Your guidance will enable me to solve the problem.

Thanks and best regards
Paul Ibison
1/6/2005 6:47:28 AM
Have a look at something like this that I use for a
related (non-replication) issue:

CREATE PROCEDURE spReturnJobState (@JobID
uniqueidentifier, @JobState int OUTPUT)
/*********************************************************
*******************************
Description: Script to return the job state of the
data load job so if it is running we can stop it.
Returns: (None)
Author: Paul Ibison (xt 26163)
Date Created: 22/12/2004
Revisions:
**********************************************************
*******************************/
AS

CREATE TABLE #xp_results (job_id UNIQUEIDENTIFIER NOT
NULL,
last_run_date INT
NOT NULL,
last_run_time INT
NOT NULL,
next_run_date INT
NOT NULL,
next_run_time INT
NOT NULL,
next_run_schedule_id INT
NOT NULL,
requested_to_run INT
NOT NULL, -- BOOL
request_source INT
NOT NULL,
request_source_id sysname
collate database_default null,
running INT
NOT NULL, -- BOOL
current_step INT
NOT NULL,
current_retry_attempt INT
NOT NULL,
job_state INT
NOT NULL)

INSERT INTO #xp_results
EXECUTE master.dbo.xp_sqlagent_enum_jobs 1, 'dbo'

SELECT @JobState = job_state FROM #xp_results WHERE
job_id = @JobID

DROP TABLE #xp_results


-- 1 = Executing, 2 = Waiting For Thread, 3 = Between
Retries, 4 = Idle, 5 = Suspended, 6 = [obsolete], 7 =
PerformingCompletionActions

Rgds,
Paul Ibison
1/6/2005 7:15:33 AM
Ah.... eureka! That explains why I keep seeing 23s in my
job history :)
Paul

[quoted text, click to view]
Paul Ibison
1/6/2005 7:53:01 AM
Kestutis,
You haven't seen my servers!!
Rgds,
Hilary Cotter
1/6/2005 9:49:59 AM
You shouldn't have to check the status as replication is essentially an
asynchronous process.

You could use sp_MSenum_replication_agents to tell you the status however.

usage is sp_MSenum_replication_Agents @type=1

where type=
1--snapshot
2--logreader
3--distribution
4--merge
5--misc
9--queue reader

here is a list of what the values in the status column represent
1--starting
2 --stopped/completed
3--executing
4--competed/idle
5--retry
6-- failed
-23 --Paul Ibison has been messing with your server



--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
[quoted text, click to view]

Kestutis Adomavicius
1/6/2005 5:08:56 PM
[quoted text, click to view]

IMHO that's one of the best possible statuses :)

--
Regards,
Kestutis Adomavicius
Consultant
UAB "Baltic Software Solutions"


[quoted text, click to view]

frankm
1/7/2005 7:53:41 AM
Try this ... it's one of those "I wrote it for myself" things...
You have to adjust the "TOP" value for the number of subscribers you have.
-------------------------
use distribution
go
select Subscriber_DB,
'Run Status' =
CASE RunStatus
WHEN 1 THEN 'Start'
WHEN 2 THEN 'Succeed'
WHEN 3 THEN 'InProgress'
WHEN 4 THEN 'Idle'
WHEN 5 THEN 'Retry'
WHEN 6 THEN 'Fail'
WHEN 23 Then 'Ibison did it'
ELSE 'Unk?'
END,
Delivery_Latency as 'Latency ms',--Delivery_Latency / 60000.00 as
'Latency mins',
cast(Duration / 3600.00 as decimal(8,2)) as 'Dur(Hrs)',
cast(Delivered_Transactions as varchar(10)) + ' (' +
cast(Delivered_Commands as varchar(12)) + ')' as 'DelTrans (cmds)',
cast(Delivery_Rate as int) as 'Del Rate',Total_Delivered_Commands as
'TotalDelCmds',
[Time],Start_Time
from MSDistribution_History join MSDistribution_Agents on Agent_ID = [ID]
where [time] in (select top 3([time]) from MSDistribution_History order by
time desc) and
name in (select distinct name from MSDistribution_Agents )
order by SubscriberDB


-----------------------------------

[quoted text, click to view]

AddThis Social Bookmark Button