Skip to content

Instantly share code, notes, and snippets.

View databoffin's full-sized avatar

Phil Grayson databoffin

View GitHub Profile
@databoffin
databoffin / ReplThroughput.sql
Created October 17, 2017 19:33
Query to track the throughput of SQL Server distribution databases
USE distribution;
GO
--Track the throughput per minute
SELECT CONVERT(SMALLDATETIME, t.entry_time) AS EntryTime,
COUNT(1) AS Commands
FROM MSrepl_commands cmds
INNER JOIN MSarticles a ON a.article_id = cmds.article_id
INNER JOIN MSrepl_transactions t ON cmds.xact_seqno = t.xact_seqno
GROUP BY CONVERT(SMALLDATETIME, t.entry_time)
ORDER BY CONVERT(SMALLDATETIME, t.entry_time) DESC;
CREATE NONCLUSTERED INDEX [IX_pubid_uploadoptions]
ON [dbo].[sysmergearticles]
(
[pubid],
[upload_options]
);
GO
CREATE NONCLUSTERED INDEX [IX_uploadoptions_Included]
ON [dbo].[sysmergearticles] ([upload_options])
INCLUDE
USE distribution;
GO
CREATE INDEX [IX_MSdistribution_history_runstatus]
ON [dbo].[MSdistribution_history] ([runstatus])
INCLUDE
(
[agent_id],
[timestamp],
[delivery_latency],
[time],
@databoffin
databoffin / CreatePullJobs.sql
Created April 28, 2017 11:05
Create SQL Server replication pull jobs
USE [msdb];
GO
DECLARE @iPublisher AS sysname;
DECLARE @iDistributor AS sysname;
DECLARE @iSubscriber AS sysname;
DECLARE @iPublication AS sysname;
DECLARE @iPublicationDB AS sysname;
DECLARE @iSubscriptionDB AS sysname;
DECLARE @job_name NVARCHAR(400);
DECLARE @cmd NVARCHAR(4000);