merge replication emails
we have many customers using merge replication on either sql 2005 or sql 2008. setup publisher if replication stops (the publication gets error - red x in replication monitor) can receive email can connect , @ it.
i haven't found documentation describing how that. point me in right direction?
darin
this prove exceptionally noisy.
i query msrepl_errors , send out recent errors me. here have done.
use [msdb] go /****** object: job [replication errors] script date: 07/28/2009 10:06:31 ******/ begin transaction declare @returncode int select @returncode = 0 /****** object: jobcategory [[uncategorized (local)]]] script date: 07/28/2009 10:06:31 ******/ if not exists (select name from msdb.dbo.syscategories where name=n'[uncategorized (local)]' and category_class=1) begin exec @returncode = msdb.dbo.sp_add_category @class=n'job', @type=n'local', @name=n'[uncategorized (local)]' if (@@error <> 0 or @returncode <> 0) goto quitwithrollback end declare @jobid binary(16) exec @returncode = msdb.dbo.sp_add_job @job_name=n'replication errors', @enabled=1, @notify_level_eventlog=0, @notify_level_email=0, @notify_level_netsend=0, @notify_level_page=0, @delete_level=0, @description=n'no description available.', @category_name=n'[uncategorized (local)]', @owner_login_name=n'repl', @job_id = @jobid output if (@@error <> 0 or @returncode <> 0) goto quitwithrollback /****** object: step [replication errors] script date: 07/28/2009 10:06:32 ******/ exec @returncode = msdb.dbo.sp_add_jobstep @job_id=@jobid, @step_name=n'replication errors', @step_id=1, @cmdexec_success_code=0, @on_success_action=1, @on_success_step_id=0, @on_fail_action=2, @on_fail_step_id=0, @retry_attempts=0, @retry_interval=0, @os_run_priority=0, @subsystem=n'tsql', @command=n' declare @tablehtml nvarchar(max) ; set @tablehtml = n''<style type="text/css">h2, body {font-family: arial, verdana;} table{font-size:11px; border-collapse:collapse;} td{background-color:#f1f1f1; border:1px solid black; padding:3px;} th{background-color:#99ccff;}</style>'' + n''<h2>replication failures</h2>'' + n''<table border="1">'' + n''<tr><th>publisher</th><th>publication</th><th>subscriber name</th><th>error message</th><th>time</th><th>name</th><th>profile id</th>'' + cast ( ( select td = srvname, '''', td = publication, '''', td = subscriber_name, '''', td = comments, '''', td = time, '''', td = name, '''', td = profile_id, '''' distribution.dbo.msmerge_history mh join distribution.dbo.msmerge_agents ma on mh.agent_id=ma.id join sys.sysservers s on s.srvid=publisher_id error_id <>0 , time>getdate()-3 order 1, 2, 3, 4, 6 xml path(''tr''), type ) nvarchar(max) ) + n''</table>'' ; exec msdb.dbo.sp_send_dbmail @recipients=''hilary.cotter@gmail.com; '', @subject = ''replication failures'', @body = @tablehtml, @profile_name=''mail'', @body_format = ''html'' ; ', @database_name=n'master', @flags=0 if (@@error <> 0 or @returncode <> 0) goto quitwithrollback exec @returncode = msdb.dbo.sp_update_job @job_id = @jobid, @start_step_id = 1 if (@@error <> 0 or @returncode <> 0) goto quitwithrollback exec @returncode = msdb.dbo.sp_add_jobschedule @job_id=@jobid, @name=n'replication errors', @enabled=1, @freq_type=4, @freq_interval=1, @freq_subday_type=8, @freq_subday_interval=4, @freq_relative_interval=0, @freq_recurrence_factor=0, @active_start_date=20080603, @active_end_date=99991231, @active_start_time=0, @active_end_time=235959 if (@@error <> 0 or @returncode <> 0) goto quitwithrollback exec @returncode = msdb.dbo.sp_add_jobserver @job_id = @jobid, @server_name = n'(local)' if (@@error <> 0 or @returncode <> 0) goto quitwithrollback commit transaction goto endsave quitwithrollback: if (@@trancount > 0) rollback transaction endsave:
looking book on sql server 2008 administration? http://www.amazon.com/microsoft-server-2008-management-administration/dp/067233044x looking book on sql server 2008 full-text search? http://www.amazon.com/pro-full-text-search-server-2008/dp/1430215941
SQL Server > SQL Server Replication
Comments
Post a Comment