d runstatus <> 2 and runstatus <> 5 and runstatus <> 6 and timestamp = (select max(timestamp) from MSlogreader_history where agent_id = @agent_id)) begin -- Log success message. exec dbo.sp_MSadd_logreader_history @agent_id = @agent_id, @runstatus = 2, @comments = @message end end else if @category_id = 10 begin -- Get agent_id select @agent_id = id from MSdistribution_agents where job_id = @job_id if exists (select runstatus from MSdistribution_history where agent_id = @agent_id and runstatus <> 2 and runstatus <> 5 and runstatus <> 6 and timestamp = (select max(timestamp) from MSdistribution_history where agent_id = @agent_id)) begin -- Log success message. exec dbo.sp_MSadd_distribution_history @agent_id = @agent_id, @runstatus = 2, @comments = @message end end else if @category_id = 14 begin -- Get agent_id select @agent_id = id from MSmerge_agents where job_id = @job_id if exists (select runstatus from MSmerge_history where agent_id = @agent_id and runstatus <> 2 and runstatus <> 5 and runstatus <> 6 and timestamp = (select max(timestamp) from MSmerge_history where agent_id = @agent_id)) begin -- Log success message. exec dbo.sp_MSadd_merge_history @agent_id = @agent_id, @runstatus = 2, @comments = @message end end else if @category_id = 19 begin -- Get agent_id select @agent_id = id from MSqreader_agents where job_id = @job_id if exists (select runstatus from MSqreader_history where agent_id = @agent_id and runstatus <> 2 and runstatus <> 5 and runstatus <> 6 and timestamp = (select max(timestamp) from MSqreader_history where agent_id = @agent_id)) begin -- Log success message. exec dbo.sp_MSadd_qreader_history @agent_id = @agent_id, @runstatus = 2, @comments = @message end end ') if @@error <> 0 return 1 exec(' create procedure sp_MSwritemergeperfcounter ( @agent_id int, @thread_num int, @counter_desc nvarchar(100), @counter_value int ) AS -- only sysadmin or db_owner have access to call this function if is_member(''db_owner'') <> 1 return 1 if (not exists (select * from sysobjects where name = ''MSmerge_perfcounters'')) begin create table MSmerge_perfcounters ( agent_id int NOT NULL, thread_num int NULL, counter_desc nvarchar(100) NOT NULL, counter_value int NOT NULL, cur_time datetime NOT NULL ) end insert into MSmerge_perfcounters values (@agent_id, @thread_num, @counter_desc, @counter_value, getdate()) return 0 ') if @@error <> 0 return 1 exec('EXEC dbo.sp_MS_marksystemobject ''sp_MSwritemergeperfcounter'' ') if @@error <> 0 return 1 exec('grant execute on sp_MSwritemergeperfcounter to public ') if @@error <> 0 return 1 exec(' create procedure sp_MSgetlasthistorytimestamp( @publisher sysname, @publisher_db sysname, @publication sysname, @subscriber sysname = NULL, @subscriber_db sysname = NULL, @last_history_logged datetime = NULL OUTPUT ) AS declare @agent_id int declare @publisher_id int declare @subscriber_id int declare @last_status int select @publisher_id = srvid from master..sysservers where UPPER(srvname) = UPPER(@publisher) select @subscriber_id = srvid from master..sysservers where UPPER(srvname) = UPPER(@subscriber) select @agent_id = id from MSmerge_agents where publisher_id = @publisher_id and publisher_db = @publisher_db and subscriber_id = @subscriber_id and subscriber_db = @subscriber_db and publication = @publication select Top 1 @last_status = runstatus, @last_history_logged = time from MSmerge_history where agent_id = @agent_id order by time DESC --failures and in-progress messages do not count, if there were previous successes. if (@last_status = 6 or @last_status = 3) and EXISTS (select * from MSmerge_history where agent_id = @agent_id and runstatus = 2) select Top 1 @last_history_logged = time from MSmerge_history where agent_id = @agent_id and runstatus = 2 order by time DESC if @last_history_logged IS NULL return 1 else return 0 ') if @@error <> 0 return 1 exec(' EXEC dbo.sp_MS_marksystemobject ''sp_MSgetlasthistorytimestamp'' ') if @@error <> 0 return 1 exec('grant execute on sp_MSgetlasthistorytimestamp to public ') if @@error <> 0 return 1 exec(' /****************************************************************************/ print '''' print ''Adding user ''''guest''''.'' print '''' /****************************************************************************/ if not exists (select * from sysusers where name = N''guest'' and hasdbaccess = 1) EXEC dbo.sp_adduser ''guest'' /****************************************************************************/ print '''' print ''Adding role ''''replmonitor''''.'' print '''' /****************************************************************************/ if not exists (select * from sysusers where name = N''replmonitor'' and issqlrole = 1) EXEC dbo.sp_addrole ''replmonitor'' grant execute on dbo.sp_MSdistribution_counters to public ') if @@error <> 0 return 1 exec('grant execute on dbo.sp_MShelp_profile to public ') if @@error <> 0 return 1 exec('grant execute on dbo.sp_MShelp_subscriber_info to public ') if @@error <> 0 return 1 exec(' -- Stored procedures used by dist and merge agents. They are granted to public grant execute on dbo.sp_MSmarkreinit to public ') if @@error <> 0 return 1 exec(' -- Procedures to retrieve actual data. Need security check inside grant execute on dbo.sp_MSget_repl_commands to public ') if @@error <> 0 return 1 exec('grant execute on dbo.sp_MSget_repl_cmds_anonymous to public ') if @@error <> 0 return 1 exec(' -- Procedures to modify meta data. Need security check inside. grant execute on dbo.sp_MSadd_distribution_history to public grant execute on dbo.sp_MSadd_repl_error to public grant execute on dbo.sp_MSadd_repl_alert to public grant execute on dbo.sp_MSadd_replmergealert to public grant execute on dbo.sp_MSadd_merge_history to public grant execute on dbo.sp_MSadd_anonymous_agent to public grant execute on dbo.sp_MSadd_merge_anonymous_agent to public grant execute on dbo.sp_MSdist_adjust_identity to public ') if @@error <> 0 return 1 exec(' -- Procedures to retrieve meta data. No security check inside. grant execute on dbo.sp_MSget_subscription_guid to public grant execute on dbo.sp_MSreset_subscription_seqno to public grant execute on dbo.sp_MSanonymous_status to public grant execute on dbo.sp_MSsubscription_status to public grant execute on dbo.sp_MShelp_merge_agentid to public grant execute on dbo.sp_MShelp_distribution_agentid to public grant execute on dbo.sp_MScheck_tran_retention to public grant execute on dbo.sp_MSenum_merge_agent_properties to public grant execute on dbo.sp_MSrepl_raiserror to public -- sp_MShelp_publication is used by the distribution control add anonymous -- subscription logic to ascertain the existence of a publication grant execute on dbo.sp_MShelp_publication to public -- sp_MSenum_replication_status to load repl monitor status table -- The status table is global and shared by all users. A user in -- replmonitor role in any dist db may load the table, the proc -- has to be granted to public. grant execute on sp_MSenum_replication_status to public ') if @@error <> 0 return 1 exec(' -- grant monitoring sps to replmonitor -- GRANT exec on sp_MShelp_publication to replmonitor GRANT exec on sp_MSenum_subscriptions to replmonitor GRANT exec on sp_MSIfExistsSubscription to replmonitor GRANT exec on sp_MSenum_merge_subscriptions to replmonitor GRANT exec on sp_MSenum_distribution to replmonitor GRANT exec on sp_MSenum_merge to replmonitor GRANT exec on sp_MSenum_snapshot to replmonitor GRANT exec on sp_MSenum_logreader to replmonitor GRANT exec on sp_MSenum_qreader to replmonitor GRANT exec on sp_MSenum_snapshot_s to replmonitor GRANT exec on sp_MSenum_logreader_s to replmonitor GRANT exec on sp_MSenum_distribution_s to replmonitor GRANT exec on sp_MSenum_merge_s to replmonitor GRANT exec on sp_MSenum_qreader_s to replmonitor GRANT exec on sp_MSenum_snapshot_sd to replmonitor GRANT exec on sp_MSenum_logreader_sd to replmonitor GRANT exec on sp_MSenum_distribution_sd to replmonitor GRANT exec on sp_MSenum_merge_sd to replmonitor GRANT exec on sp_MSenum_qreader_sd to replmonitor GRANT exec on sp_MSget_repl_error to replmonitor ') if @@error <> 0 return 1 exec(' declare @dbname sysname select @dbname = db_name() execute(''dump transaction '' +@dbname+ '' with no_log'') ') if @@error <> 0 return 1 exec('checkpoint ') if @@error <> 0 return 1 exec(' exec dbo.sp_MS_upd_sysobj_category 2 --Now do catalog updates. ') if @@error <> 0 return 1 exec(' EXEC dbo.sp_configure ''allow updates'', 0 ') if @@error <> 0 return 1 exec(' reconfigure with override ') if @@error <> 0 return 1 exec('-- - ---- ') if @@error <> 0 return 1 end go exec dbo.sp_MS_marksystemobject 'sp_instdist' go dump tran master with no_log go sp_configure 'allow updates',0 go reconfigure with override go s h1YY鬲@ PPYPjjj0h9P$p@Pjjj0h8h8ssX Ey$H@ 6fxRYujsjNjsjK]3Cjs j#ujs j$ihdȤMsshVKEH 鸯hHȤssj9$hssW ezt'd, p+@@sEsjs]C.jhקss]C.*jhקssssj[M]C.頛M]C.*鋛3VVVs3YYPV蘀Eȃ@.3PPP3PfKfH(@.hhs3V hLԧh<ԧhss^V3 ;ƉE~,CPSʀVVVPVuEF.V 顜h<ԧssjhssV3 ;ƉE~%VVV3VMUH. ;שh<ԧssjnhssU3 ;ƉE~VVV3VjMUH. ;h$ȤMssh|KEH f`V)hȤssj)M| EH f`VhssU e\hǤsshhs3T h,ԧ:hssT3 ;ƉE~2CPS8VVVPV|~MH.Mы ;ы h,ԧchsstT3 ;ƉE~%VVV3V-~MUH. ;Gh,ԧkhss)T3 ;ƉE~%VVV3V}MUH. ;h,ԧssjh ssS fCЋU@.(  CPS&~3VVVPVh}M@.у ;ы 3VVV3V?}U@. ;[h0ssGS3 ;ƉE}h,ԧssj&VVVsV|MUH.  ;+++++++++++++++++*+++**+++++++++++++V׬V+++++++++++++++++++++++++++++++++,+VׁV++++++++++++++++++++++++*++++++++++,+V׬׬++++++++++++++++++++*++++++++,V+׬++++++++++++++++++++++++*+++++++++,++VVV׬+++++++++++++++++++**+*+++++++++,++UV׬+++++++++++++++++++++++++++++++++VV,V׬++++++++++++++++++++*++++++,V+V+*V׬+++++++++++++++++++++++++++++++++++++U,U,V׬++++++++++++++++++++++,U,+VUV+V׬+++++++++++++++++++++++++++++++*+++++++V+,V+׬++++++++++++++++++++++++++++++++++V+,+++++++U,U,UV++++++++++++++++++++++++++++V+++UVV++,+++++++VVV+++++++++++++++++++++++++++++++V++VU,++,,++,VVVV+++++V+++++++++++++++++++++++++++++U++++V+,UVV+++,,VVVVVVVV+++++׬++++++++++++++++++++++++,+++,U,U,+VU,+,,,,VVVVVVWV++׬++++++++++++++++++++++++++++U,U+V,UV,VV,,+,,VVVVVWVVVV++׬+++++++++++++++++++++++++++V++V++U,UVU,+,,,VVVWVVV+++׬++++++++++++++++++++++++++V++V++V++VV,VVV,,,,,VVVVVVWV++׬+++++++++++++++++++++++++++V++V+VVV+VVV,V,,,VVWWV++V׬++++++++++++++++++++++++V+V+V+VV+VV+VVVVVV,,,VVVVV++׬+++++++++++++++++++++V+++++V++VV+VVVVVVV,,,VVVV+Vׁׁ++++++++++++++++++++++++V+V++VV+VVVVVVVVV,,,V++׬Uׁ+++++++++++++++++++++V++V+V+V+VVV+VVVVVVVVV,,++Vׁ++++++++++++++++++++V++V+V+VV+VVVVVVVVVV,++Uׁ++++++++++++++++++++V+++V++V+V+VVVVVVVVVV,+VֱՀׁ+++++++++++++V+V+++V++VV+VVVVVVVVVVV+++Wֲׁ++++++++++++++++++++++V+V+VV+VVVVVVVVVV+,ײUV+++++++++++++++++++V+V+V+VV+VVVVVVVV+++,ֲժV+++++++++++++++V++V++V+V+V+VVVVVVVV+Pֱ*׬V+++++++++++++++++V++V+V+VVVVVVVV+++Vֲ׬V+++++++++V+V+VVV+VVV+V++++׭ֱի׬V+++V׭ֲU׬VV++VѭֱՀ׬VVVVVVVVVV׭׭׬իײ+ֲֲժϲֲֲ*ՀUիUժ+ժ+ՀUUUUՀժի + Հ ժ + Հ * Հ + ժ 55 U 55  5 55 5 Հ 5 55 5 U 55 55 55 * 55 55 55 ի 5 55WW 5 Հ 5 5W,, 5  5W, + 55, + 5W,  5,,, 55,, ի 55W, ժ 55555 55W, 55555 ժ 55W,5 ժ _5W,,,,_ ժ 55555 55W,,,,,,5 55555 5W,,,,,,, 5W,,,,,,,  5W,,,,,,, + 5W,,W,, U W,, ,, Հ 5W,WW, ժ 5 _,,,,_ 5  5 5 5 U 55 55 Հ 55 55 55  5 55 5 U 5 55 5 Հ 55  55 Հ  U * Հ + ի* Հ U+*ժ**+UՀ+ժ*(11 f3f3̙f3fffff3ff333f3333f3f3f3̙f3fffff3ff333f3333f3f3̙̙̙f̙3̙̙̙f3fffff3ff333f3333f3fffff3fffffff3fff̙ffff3fffffffffff3ffff3f3f3ff3f33f3ffffff3ff333f3333333f33333̙33f3333f3f3f3ff33f3f3333333f3333333333f3333f3f3̙f3fffff3ff333f3333f33f̙3ffffffffff!___www         55  55  5 55 5  5 55 5  55 55 55  55 55 55  5 55WW 5  5 5W,, 5  5W, 55,  5W,  5,,,  55,, 55W, 55555 55W, 55555 55W,5 _5W,,,,_ 55555 55W,,,,,,5 55555 5W,,,,,,, 5W,,,,,,, 5W,,,,,,,  5W,,W,,  W,, ,,  5W,WW,  5 _,,,,_ 5  5 5 5  55 55  55 55 55  5 55 5  5 55 5  55  55          ( /"""/""/"///( (9Lf3f3̙f3fffff3ff333f3333f3f3f3̙f3fffff3ff333f3333f3f3̙̙̙f̙3̙̙̙f3fffff3ff333f3333f3fffff3fffffff3fff̙ffff3fffffffffff3ffff3f3f3ff3f33f3ffffff3ff333f3333333f33333̙33f3333f3f3f3ff33f3f3333333f3333333333f3333f3f3̙f3fffff3ff333f3333f3+ժՀUU+ի*ժՀՀՀՀUUUUUՀՀՀՀժիի*+UՀ