sync
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# SQL Server Management Studio Solution File, Format Version 19.00
|
||||
VisualStudioVersion = 15.0.28307.421
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "PULL replication perf validation", "PULL replication perf validation\PULL replication perf validation.ssmssqlproj", "{E5698C40-2FA1-4763-AA8F-B68F187E8CA2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Default|Default = Default|Default
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E5698C40-2FA1-4763-AA8F-B68F187E8CA2}.Default|Default.ActiveCfg = Default
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {985B29D4-A5B5-4FA7-90CC-99FD4ACBCB7C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Binary file not shown.
@@ -0,0 +1,256 @@
|
||||
<?xml version="1.0"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="PULL replication perf validation">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" Sorted="true">
|
||||
<Items>
|
||||
<ConnectionNode Name="CCVI50145250T53:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:50:37.8213395+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145250T53</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145251T55:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:50:29.2840238+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145251T55</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145252T60:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:50:00.6473895+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145252T60</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145253T61:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:53.4457553+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145253T61</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145254T62:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:48.7120403+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145254T62</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145255T63:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:42.4488992+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145255T63</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145353T02:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:37.6276426+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145353T02</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145357T50:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:32.171788+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145357T50</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145358T51:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:27.0634995+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145358T51</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145359T52:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:22.2220357+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145359T52</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145360T54:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:18.333537+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145360T54</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145361T56:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:14.5006214+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145361T56</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145362T57:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:10.596207+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145362T57</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145363T58:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:49:01.941259+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145363T58</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145364T59:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:48:57.7881635+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145364T59</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="CCVI50145365T64:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:48:52.2353285+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>CCVI50145365T64</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName />
|
||||
</ConnectionNode>
|
||||
<ConnectionNode Name="SWCVI501VM01\APSSQL:CENTRALINFRA\ua208700">
|
||||
<Created>2023-10-18T14:44:46.507716+02:00</Created>
|
||||
<Type>SQL</Type>
|
||||
<Server>SWCVI501VM01\APSSQL</Server>
|
||||
<UserName />
|
||||
<Authentication>Windows Authentication</Authentication>
|
||||
<InitialDB />
|
||||
<LoginTimeout>30</LoginTimeout>
|
||||
<ExecutionTimeout>0</ExecutionTimeout>
|
||||
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
|
||||
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
|
||||
</ConnectionNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Queries" Type="0" Sorted="true">
|
||||
<Items>
|
||||
<FileNode Name="activepos_read.dbo.CreateActivePosPublication.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:SWCVI501VM01\APSSQL:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>SWCVI501VM01\APSSQL</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>activepos_read.dbo.CreateActivePosPublication.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="activepos_server.dbo.addsubscription.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:SWCVI501VM01\APSSQL:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>SWCVI501VM01\APSSQL</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>activepos_server.dbo.addsubscription.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="replication snippet.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:SWCVI501VM01\APSSQL:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>SWCVI501VM01\APSSQL</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>replication snippet.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="restore activepos_read on POS.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:CCVI50145362T57:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>CCVI50145362T57</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>restore activepos_read on POS.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="test IIICUSTOMER perfs.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:SWCVI501VM01\APSSQL:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>SWCVI501VM01\APSSQL</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>test IIICUSTOMER perfs.sql</FullPath>
|
||||
</FileNode>
|
||||
<FileNode Name="test IIIPartner_Item_Details perfs.sql">
|
||||
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:SWCVI501VM01\APSSQL:True</AssociatedConnectionMoniker>
|
||||
<AssociatedConnSrvName>SWCVI501VM01\APSSQL</AssociatedConnSrvName>
|
||||
<AssociatedConnUserName />
|
||||
<FullPath>test IIIPartner_Item_Details perfs.sql</FullPath>
|
||||
</FileNode>
|
||||
</Items>
|
||||
</LogicalFolder>
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
|
||||
<Items />
|
||||
</LogicalFolder>
|
||||
</Items>
|
||||
</SqlWorkbenchSqlProject>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,87 @@
|
||||
IF OBJECT_ID('dbo.ReplicationServerAgentStartStop') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE dbo.ReplicationServerAgentStartStop
|
||||
END
|
||||
GO
|
||||
|
||||
/*=============================================================================
|
||||
|
||||
TPDT-133
|
||||
|
||||
This proc will allow the activePosClientService to manage is a replication agent is running on the pharmacy server
|
||||
|
||||
Parameters
|
||||
----------------------
|
||||
@posName varchar(255), no default The name of the POS we want to manage the replication agent of
|
||||
@statusRun bit, no default If set to 0, we will stop or let the job as stopped. if set to 1, we will try to start the job
|
||||
|
||||
Context
|
||||
----------------------
|
||||
This proc is to be called from activePosClientService, in a push / pull replication.
|
||||
We need to ensure that the distribution of the snapshot is not done from the pharmacy server, but from the pos.
|
||||
For this, we need to ensure that the agent is stopped after the subscriber is created or when we requests a re-init of the POS.
|
||||
|
||||
Creation : 26.10.2023 / TSC
|
||||
Modifications:
|
||||
|
||||
=============================================================================*/
|
||||
CREATE PROCEDURE [dbo].[ReplicationServerAgentStartStop]
|
||||
@posName VARCHAR(255),
|
||||
@statusRun BIT
|
||||
AS
|
||||
BEGIN
|
||||
SET XACT_ABORT ON;
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @jobIsRunning BIT = 0;
|
||||
DECLARE @jobName sysname;
|
||||
SELECT @jobName = [j].[name]
|
||||
FROM msdb.dbo.[sysjobs] j
|
||||
WHERE [j].[name] = 'ActivePosTran distribution agent - ' + @posName;
|
||||
|
||||
IF NOT EXISTS ( SELECT 1
|
||||
FROM [Arizona].[dbo].[Point_of_sale] s
|
||||
WHERE [s].[POS_hostname] = @posName)
|
||||
BEGIN
|
||||
RAISERROR('The POS %s is not registered on Point_of_sale', 14, 1, @posName);
|
||||
END;
|
||||
|
||||
IF @jobName IS NULL
|
||||
BEGIN
|
||||
RAISERROR(
|
||||
'Agent "ActivePosTran distribution agent - %s" does not exists, publication must bre re-created', 14, 1, @posName);
|
||||
END;
|
||||
|
||||
IF EXISTS(
|
||||
SELECT [job].[name],
|
||||
job.job_id,
|
||||
[job].[originating_server],
|
||||
[activity].[run_requested_date],
|
||||
DATEDIFF(SECOND, [activity].[run_requested_date], GETDATE()) AS Elapsed
|
||||
FROM msdb.dbo.sysjobs_view job
|
||||
JOIN msdb.dbo.sysjobactivity activity
|
||||
ON job.job_id = activity.job_id
|
||||
JOIN msdb.dbo.syssessions sess
|
||||
ON sess.session_id = activity.session_id
|
||||
JOIN ( SELECT MAX(agent_start_date) AS max_agent_start_date
|
||||
FROM msdb.dbo.syssessions) sess_max
|
||||
ON [sess].[agent_start_date] = [sess_max].[max_agent_start_date]
|
||||
WHERE [activity].[run_requested_date] IS NOT NULL
|
||||
AND [activity].[stop_execution_date] IS NULL
|
||||
AND [job].[name] ='ActivePosTran distribution agent - ' + @posName
|
||||
)
|
||||
BEGIN
|
||||
SET @jobIsRunning = 1
|
||||
END
|
||||
|
||||
IF @statusRun = 0 AND @jobIsRunning = 1
|
||||
BEGIN
|
||||
EXEC [msdb].[dbo].[sp_stop_job] @job_name = @jobName;
|
||||
END
|
||||
|
||||
IF @statusRun = 1 AND @jobIsRunning = 0
|
||||
BEGIN
|
||||
EXEC [msdb].[dbo].[sp_start_job] @job_name = @jobName;
|
||||
END
|
||||
|
||||
END;
|
||||
Binary file not shown.
@@ -0,0 +1,358 @@
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
/*=================================================================================================
|
||||
TPDT-133
|
||||
This procedure is derived from AddSubscriptionWithBackup, but to have snapshot used for initialization
|
||||
|
||||
26.10.2023 TSC Creation
|
||||
|
||||
* Modifications :
|
||||
10.11.2023 TSC Ensure that server agent is stopped before creating the subscription (to avoid this agent starting the init)
|
||||
*=================================================================================================*/
|
||||
ALTER PROCEDURE [dbo].[AddSubscriptionWithSnapshot]
|
||||
@posName VARCHAR(255),
|
||||
@dbVersion VARCHAR(20)
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @query1 VARCHAR(MAX),
|
||||
@query2 VARCHAR(MAX),
|
||||
@finalQuery NVARCHAR(MAX),
|
||||
@message NVARCHAR(MAX),
|
||||
@posSubscription VARCHAR(255),
|
||||
@serverDbVersion VARCHAR(20),
|
||||
@ParmDefinition NVARCHAR(1000),
|
||||
@returnCode INT;
|
||||
|
||||
DECLARE @jobId BINARY(16),
|
||||
@jobname VARCHAR(128),
|
||||
@CommandTSQL NVARCHAR(MAX),
|
||||
@CommandTSQL2 NVARCHAR(MAX);
|
||||
|
||||
SET @finalQuery = N'';
|
||||
SET @posSubscription = REPLACE(@posName, '-', '');
|
||||
|
||||
/* Check if ActivePos_write versions are the same */
|
||||
SELECT @serverDbVersion = [ActivePos_write].[upd].[DatabaseVersion]();
|
||||
IF @serverDbVersion <> @dbVersion
|
||||
BEGIN
|
||||
SET @message
|
||||
= N'ActivePos_write version (' + @dbVersion + N') of host ''' + @posSubscription
|
||||
+ N''' is not the same as the server version (' + @serverDbVersion + N').';
|
||||
RAISERROR(@message, 16, -1);
|
||||
END;
|
||||
|
||||
/* Check if the subscription already exists for this pos */
|
||||
|
||||
IF OBJECT_ID('tempdb..#tt_repli')IS NOT NULL BEGIN;
|
||||
DROP TABLE #tt_repli;
|
||||
END;
|
||||
|
||||
SELECT *
|
||||
INTO #tt_repli
|
||||
FROM OPENROWSET (
|
||||
'SQLNCLI'
|
||||
, 'DRIVER={SQL Server};server=.\apssql;Trusted_Connection=yes;'
|
||||
, 'EXEC [ActivePos_read].[sys].[sp_helpsubscription] @publication = ''ActivePosTran'', @article = ''IIISales_order_header'' WITH RESULT SETS (([subscriber] nvarchar(128), [publication] nvarchar(128), [article] nvarchar(128), [destination database] nvarchar(128), [subscription status] int, [synchronization type] tinyint, [subscription type] int, [full subscription] bit, [subscription name] nvarchar(386), [update mode] int, [distribution job id] varbinary(16), [loopback_detection] bit, [offload_enabled] bit, [offload_server] nvarchar(128), [dts_package_name] nvarchar(128), [dts_package_location] int, [subscriber_security_mode] smallint, [subscriber_login] nvarchar(128), [subscriber_password] varchar(10), [job_login] nvarchar(128), [job_password] varchar(10), [distrib_agent_name] nvarchar(100), [subscriber_type] tinyint, [subscriber_provider] nvarchar(128), [subscriber_datasource] nvarchar(4000), [subscriber_providerstring] nvarchar(4000), [subscriber_location] nvarchar(4000), [subscriber_catalog] nvarchar(128)));')
|
||||
|
||||
IF NOT EXISTS ( SELECT 1 FROM [#tt_repli] t WHERE t.[subscriber] = @posName)
|
||||
BEGIN
|
||||
BEGIN TRY
|
||||
PRINT @posSubscription + ' : there is no subscription for the pos in the replication !';
|
||||
/* Check the linked server exists */
|
||||
IF NOT EXISTS ( SELECT TOP 1 *
|
||||
FROM [sys].[servers]
|
||||
WHERE [name] = @posSubscription)
|
||||
BEGIN
|
||||
PRINT 'There is no linked server for this pos :' + @posName;
|
||||
RAISERROR(N'There is no linked server for this pos :', 13, 1);
|
||||
END;
|
||||
/* Check that the Pos responds */
|
||||
SELECT @finalQuery = N'EXEC (''SELECT TOP 1 * FROM ActivePos_write..keyTable'')' + N' AT ' + @posSubscription;
|
||||
EXEC (@finalQuery);
|
||||
|
||||
/* Create the push subscription */
|
||||
SET @finalQuery = N'';
|
||||
SELECT @finalQuery
|
||||
= REPLACE(
|
||||
'USE [ActivePos_Read]; EXEC @returnCodeOut = sp_addsubscription @publication = N''ActivePosTran'', @subscriber =''@sub@'',@destination_db = N''ActivePos_read'',@subscription_type = N''push'' ',
|
||||
'@sub@',
|
||||
@posSubscription);
|
||||
|
||||
RAISERROR(@finalQuery, 0, 1) WITH NOWAIT;
|
||||
SELECT @ParmDefinition = N'@returnCodeOut int output';
|
||||
|
||||
EXEC dbo.[ReplicationServerAgentStartStop] @posName = @posName,
|
||||
@statusRun = 0
|
||||
|
||||
|
||||
EXECUTE [sys].[sp_executesql] @finalQuery,
|
||||
@ParmDefinition,
|
||||
@returnCodeOut = @returnCode OUTPUT;
|
||||
IF @returnCode = 0
|
||||
BEGIN
|
||||
SELECT @message = N'The subscription for Pos' + @posName + N' was successfully added';
|
||||
RAISERROR(@message, 0, 1) WITH NOWAIT;
|
||||
END;
|
||||
ELSE
|
||||
BEGIN
|
||||
SELECT @message = N'The subscription for Pos' + @posName + N' was not correctly added and must be dropped';
|
||||
SET @finalQuery = N'';
|
||||
SELECT @finalQuery
|
||||
= N'USE [ActivePos_Read]; EXEC @returnCodeOut = sp_dropsubscription @publication = N''ActivePosTran'','
|
||||
+ N'@article = N''all'', @subscriber =' + @posSubscription;
|
||||
EXECUTE [sys].[sp_executesql] @finalQuery,
|
||||
@ParmDefinition,
|
||||
@returnCodeOut = @returnCode OUTPUT;
|
||||
SELECT @message = N'could not successfully complete registration for pos :' + @posName;
|
||||
RAISERROR(@message, 14, 1);
|
||||
RETURN;
|
||||
END;
|
||||
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
SELECT @message = ERROR_MESSAGE();
|
||||
SELECT @message = N'Error occurred during push subscription creation on POS ' + @posName + N' ' + @message;
|
||||
RAISERROR(@message, 14, 1);
|
||||
RETURN;
|
||||
END CATCH;
|
||||
END;
|
||||
|
||||
/* Add or update the subscription agent : to be run at Publisher */
|
||||
BEGIN TRY
|
||||
|
||||
/* Create distribution agent if not exists */
|
||||
IF NOT EXISTS ( SELECT 1
|
||||
FROM [msdb].[dbo].[sysjobs]
|
||||
WHERE [name] = N'ActivePosTran distribution agent - ' + @posName + '')
|
||||
BEGIN
|
||||
|
||||
/* Creation Job and Steps*/
|
||||
DECLARE @cmd VARCHAR(MAX),
|
||||
@publisher NVARCHAR(200),
|
||||
@subscriber VARCHAR(200),
|
||||
@environment VARCHAR(10);
|
||||
|
||||
SET @returnCode = 0;
|
||||
SET @publisher = CAST(SERVERPROPERTY('ServerName') AS NVARCHAR(100));
|
||||
SET @subscriber = @posName;
|
||||
|
||||
IF NOT EXISTS ( SELECT [name]
|
||||
FROM [msdb].[dbo].[syscategories]
|
||||
WHERE [name] = N'REPL-Distribution'
|
||||
AND [category_class] = 1)
|
||||
BEGIN
|
||||
EXEC @returnCode = [msdb].[dbo].[sp_add_category] @class = N'JOB',
|
||||
@type = N'LOCAL',
|
||||
@name = N'REPL-Distribution';
|
||||
END;
|
||||
|
||||
/* Add Job */
|
||||
|
||||
SET @jobname = 'ActivePosTran distribution agent - ' + @posName + '';
|
||||
SET @CommandTSQL
|
||||
= N'DECLARE @agentIDAPH int
|
||||
|
||||
SELECT @agentIDAPH = [id] FROM [distribution].[dbo].[MSdistribution_agents] WHERE name = ''ActivePosTran distribution agent - '
|
||||
+ @posName
|
||||
+ N'''
|
||||
|
||||
EXEC sp_MSadd_distribution_history @perfmon_increment = 0, @agent_id = @agentIDAPH, @runstatus = 1,
|
||||
@comments = N''Starting agent.''';
|
||||
|
||||
SET @CommandTSQL2
|
||||
= N'DECLARE @agentIDAPH int
|
||||
|
||||
SELECT @agentIDAPH = [id] FROM [distribution].[dbo].[MSdistribution_agents] WHERE name = ''ActivePosTran distribution agent - '
|
||||
+ @posName
|
||||
+ N'''
|
||||
|
||||
EXEC sp_MSdetect_nonlogged_shutdown @subsystem = ''Distribution'', @agent_id = @agentIDAPH';
|
||||
|
||||
EXEC @returnCode = [msdb].[dbo].[sp_add_job] @job_name = @jobname,
|
||||
@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'REPL-Distribution',
|
||||
@start_step_id = 1,
|
||||
@owner_login_name = N'sa',
|
||||
@job_id = @jobId OUTPUT;
|
||||
|
||||
/* Add Step */
|
||||
EXEC @returnCode = [msdb].[dbo].[sp_add_jobstep] @job_id = @jobId,
|
||||
@step_name = N'Distribution Agent startup message.',
|
||||
@step_id = 1,
|
||||
@cmdexec_success_code = 0,
|
||||
@on_success_action = 3,
|
||||
@on_success_step_id = 0,
|
||||
@on_fail_action = 3,
|
||||
@on_fail_step_id = 0,
|
||||
@retry_attempts = 0,
|
||||
@retry_interval = 0,
|
||||
@os_run_priority = 0,
|
||||
@subsystem = N'TSQL',
|
||||
@command = @CommandTSQL,
|
||||
@database_name = N'distribution',
|
||||
@output_file_name = NULL,
|
||||
@flags = 0,
|
||||
@database_user_name = NULL,
|
||||
@server = @publisher,
|
||||
@additional_parameters = NULL,
|
||||
@proxy_id = NULL,
|
||||
@proxy_name = NULL;
|
||||
|
||||
/* Add Step */
|
||||
/*Build commands */
|
||||
SET @cmd
|
||||
= '-Subscriber [' + @subscriber + '] -SubscriberDB [ActivePos_read] -Publisher [' + @publisher
|
||||
+ '] -Distributor [' + @publisher
|
||||
+ '] -DistributorSecurityMode 1 -Publication [ActivePosTran] -PublisherDB [ActivePos_read] -ErrorFile G:\sqlLogs\Distrib_'
|
||||
+ @posName + '.err -Continuous';
|
||||
EXEC @returnCode = [msdb].[dbo].[sp_add_jobstep] @job_id = @jobId,
|
||||
@step_name = N'Run agent.',
|
||||
@step_id = 2,
|
||||
@cmdexec_success_code = 0,
|
||||
@on_success_action = 1,
|
||||
@on_success_step_id = 0,
|
||||
@on_fail_action = 3,
|
||||
@on_fail_step_id = 0,
|
||||
@retry_attempts = 2147483647,
|
||||
@retry_interval = 1,
|
||||
@os_run_priority = 0,
|
||||
@subsystem = N'Distribution',
|
||||
@command = @cmd,
|
||||
@database_name = N'distribution',
|
||||
@output_file_name = NULL,
|
||||
@flags = 0,
|
||||
@database_user_name = NULL,
|
||||
@server = @publisher,
|
||||
@additional_parameters = NULL,
|
||||
@proxy_name = N'[REPL][aphsqlrepl][ActivePos_read]';
|
||||
|
||||
/* Add Step */
|
||||
EXEC @returnCode = [msdb].[dbo].[sp_add_jobstep] @job_id = @jobId,
|
||||
@step_name = N'Detect nonlogged agent shutdown.',
|
||||
@step_id = 3,
|
||||
@cmdexec_success_code = 0,
|
||||
@on_success_action = 2,
|
||||
@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 = @CommandTSQL2,
|
||||
@database_name = N'distribution',
|
||||
@output_file_name = NULL,
|
||||
@flags = 0,
|
||||
@database_user_name = NULL,
|
||||
@server = @publisher,
|
||||
@additional_parameters = NULL,
|
||||
@proxy_id = NULL,
|
||||
@proxy_name = NULL;
|
||||
|
||||
EXEC @returnCode = [msdb].[dbo].[sp_update_job] @job_id = @jobId,
|
||||
@start_step_id = 1;
|
||||
|
||||
/* Add schedule : */
|
||||
DECLARE @schedule_id2 INT;
|
||||
EXEC [msdb].[dbo].[sp_add_jobschedule] @job_name = @jobname,
|
||||
@name = N'ReplicationAgent Start auto',
|
||||
@enabled = 1,
|
||||
@freq_type = 64,
|
||||
@freq_interval = 1,
|
||||
@freq_subday_type = 0,
|
||||
@freq_subday_interval = 0,
|
||||
@freq_relative_interval = 0,
|
||||
@freq_recurrence_factor = 1,
|
||||
@active_start_date = 20220316,
|
||||
@active_end_date = 99991231,
|
||||
@active_start_time = 0,
|
||||
@active_end_time = 235959,
|
||||
@schedule_id = @schedule_id2 OUTPUT;
|
||||
|
||||
|
||||
EXEC @returnCode = [msdb].[dbo].[sp_add_jobserver] @job_id = @jobId,
|
||||
@server_name = N'(local)';
|
||||
|
||||
/*
|
||||
do not start agent automatically, we must first init the subscriber from the POS to avoid lan traffic
|
||||
*/
|
||||
--EXEC [msdb].[dbo].[sp_start_job] @jobname;
|
||||
EXEC [ActivePos_server].[dbo].[ReplicationServerAgentStartStop] @posName = @posName,
|
||||
@statusRun = 0
|
||||
|
||||
|
||||
END;
|
||||
|
||||
SELECT @finalQuery = N'';
|
||||
SELECT @query1
|
||||
= 'declare @JobName varchar(100)
|
||||
|
||||
declare c_job cursor local forward_only static for
|
||||
SELECT name from msdb.dbo.sysjobs
|
||||
where name like ''%ActivePos_read-ActivePosTran%''
|
||||
AND name like ''%' + REPLACE(@posName, '-', '')
|
||||
+ '%''
|
||||
|
||||
open c_job
|
||||
|
||||
FETCH NEXT FROM c_job
|
||||
into @JobName
|
||||
|
||||
WHILE @@fetch_status = 0
|
||||
BEGIN
|
||||
|
||||
EXEC msdb.dbo.sp_delete_job @job_name = @JobName
|
||||
|
||||
FETCH NEXT FROM c_job
|
||||
into @JobName
|
||||
END
|
||||
|
||||
close c_job
|
||||
deallocate c_job
|
||||
|
||||
USE [ActivePos_Read]; EXEC sp_addpushsubscription_agent @publication = N''ActivePosTran'', @subscriber = ';
|
||||
SELECT @query2
|
||||
= ',
|
||||
@subscriber_db = N''ActivePos_read'', @job_password = null,@subscriber_security_mode = 1,
|
||||
@job_name = N''ActivePosTran distribution agent - ' + @posName
|
||||
+ ''',
|
||||
@frequency_interval = 0, @frequency_relative_interval = 0,
|
||||
@frequency_subday = 0, @frequency_subday_interval = 0';
|
||||
|
||||
SELECT @query1 = REPLACE(@query1, '''', '''''');
|
||||
SELECT @query2 = REPLACE(@query2, '''', '''''');
|
||||
|
||||
SELECT @finalQuery = @finalQuery + N'EXEC (''' + @query1 + REPLACE(@posName, '-', '') + @query2 + N''')';
|
||||
IF EXISTS ( SELECT 1
|
||||
FROM [distribution].[dbo].[MSdistribution_agents]
|
||||
WHERE CHARINDEX(REPLACE(@posName, '-', ''), [name]) > 0
|
||||
AND [subscriber_security_mode] = 1
|
||||
AND [subscriber_db] = 'ActivePos_read')
|
||||
BEGIN
|
||||
EXEC (@finalQuery);
|
||||
SELECT @message = N'The subscription agent for Pos ' + @posName + N' was explicitly created';
|
||||
RAISERROR(@message, 0, 1) WITH NOWAIT;
|
||||
END;
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
SELECT @message = ERROR_MESSAGE();
|
||||
SELECT @message = N'Error during subscription agent creation on POS ' + @posName + N' ' + @message;
|
||||
RAISERROR(@message, 14, 1);
|
||||
END CATCH;
|
||||
|
||||
EXEC [master].[dbo].[sp_serveroption] @server = @posName,
|
||||
@optname = N'data access',
|
||||
@optvalue = N'true';
|
||||
EXEC [master].[dbo].[sp_serveroption] @server = @posName,
|
||||
@optname = N'remote proc transaction promotion',
|
||||
@optvalue = N'true';
|
||||
END;
|
||||
GO
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Taken from https://stackoverflow.com/a/4036445
|
||||
|
||||
How do I check SQL replication status via T-SQL?
|
||||
|
||||
*/
|
||||
|
||||
SELECT
|
||||
(CASE
|
||||
WHEN mdh.runstatus = '1' THEN 'Start - '+cast(mdh.runstatus as varchar)
|
||||
WHEN mdh.runstatus = '2' THEN 'Succeed - '+cast(mdh.runstatus as varchar)
|
||||
WHEN mdh.runstatus = '3' THEN 'InProgress - '+cast(mdh.runstatus as varchar)
|
||||
WHEN mdh.runstatus = '4' THEN 'Idle - '+cast(mdh.runstatus as varchar)
|
||||
WHEN mdh.runstatus = '5' THEN 'Retry - '+cast(mdh.runstatus as varchar)
|
||||
WHEN mdh.runstatus = '6' THEN 'Fail - '+cast(mdh.runstatus as varchar)
|
||||
ELSE CAST(mdh.runstatus AS VARCHAR)
|
||||
END) [Run Status],
|
||||
mdh.runstatus,
|
||||
mda.subscriber_db [Subscriber DB],
|
||||
mda.publication [PUB Name],
|
||||
right(left(mda.name,LEN(mda.name)-(len(mda.id)+1)), LEN(left(mda.name,LEN(mda.name)-(len(mda.id)+1)))-(10+len(mda.publisher_db)+(case when mda.publisher_db='ALL' then 1 else LEN(mda.publication)+2 end))) [SUBSCRIBER],
|
||||
CONVERT(VARCHAR(25),mdh.[time]) [LastSynchronized],
|
||||
und.UndelivCmdsInDistDB [UndistCom],
|
||||
mdh.comments [Comments],
|
||||
--'select * from distribution.dbo.msrepl_errors (nolock) where id = ' + CAST(mdh.error_id AS VARCHAR(8)) [Query More Info],
|
||||
--mdh.xact_seqno [SEQ_NO],
|
||||
(CASE
|
||||
WHEN mda.subscription_type = '0' THEN 'Push'
|
||||
WHEN mda.subscription_type = '1' THEN 'Pull'
|
||||
WHEN mda.subscription_type = '2' THEN 'Anonymous'
|
||||
ELSE CAST(mda.subscription_type AS VARCHAR)
|
||||
END) [SUB Type],
|
||||
|
||||
mda.publisher_db+' - '+CAST(mda.publisher_database_id AS VARCHAR) [Publisher DB],
|
||||
mda.name [Pub - DB - Publication - SUB - AgentID]
|
||||
FROM distribution.dbo.MSdistribution_agents mda
|
||||
LEFT JOIN distribution.dbo.MSdistribution_history mdh ON mdh.agent_id = mda.id
|
||||
JOIN
|
||||
(SELECT s.agent_id, MaxAgentValue.[time], SUM(CASE WHEN xact_seqno > MaxAgentValue.maxseq THEN 1 ELSE 0 END) AS UndelivCmdsInDistDB
|
||||
FROM distribution.dbo.MSrepl_commands t (NOLOCK)
|
||||
JOIN distribution.dbo.MSsubscriptions AS s (NOLOCK) ON (t.article_id = s.article_id AND t.publisher_database_id=s.publisher_database_id )
|
||||
JOIN
|
||||
(SELECT hist.agent_id, MAX(hist.[time]) AS [time], h.maxseq
|
||||
FROM distribution.dbo.MSdistribution_history hist (NOLOCK)
|
||||
JOIN (SELECT agent_id,ISNULL(MAX(xact_seqno),0x0) AS maxseq
|
||||
FROM distribution.dbo.MSdistribution_history (NOLOCK)
|
||||
GROUP BY agent_id) AS h
|
||||
ON (hist.agent_id=h.agent_id AND h.maxseq=hist.xact_seqno)
|
||||
GROUP BY hist.agent_id, h.maxseq
|
||||
) AS MaxAgentValue
|
||||
ON MaxAgentValue.agent_id = s.agent_id
|
||||
GROUP BY s.agent_id, MaxAgentValue.[time]
|
||||
) und
|
||||
ON mda.id = und.agent_id AND und.[time] = mdh.[time]
|
||||
where mda.subscriber_db<>'virtual' -- created when your publication has the immediate_sync property set to true. This property dictates whether snapshot is available all the time for new subscriptions to be initialized. This affects the cleanup behavior of transactional replication. If this property is set to true, the transactions will be retained for max retention period instead of it getting cleaned up as soon as all the subscriptions got the change.
|
||||
--and mdh.runstatus='6' --Fail
|
||||
--and mdh.runstatus<>'2' --Succeed
|
||||
order by mdh.[time]
|
||||
@@ -0,0 +1,88 @@
|
||||
SELECT [pos].[POS_hostname], [pos].[POS_MAC_address], [pos].[POS_number], [pos].[POS_type]
|
||||
FROM [Arizona].[dbo].[Point_of_sale] [pos]
|
||||
WHERE [pos].[POS_active]=1
|
||||
AND [pos].[POS_type] IN (1,2)
|
||||
AND [pos].[POS_number] < 99
|
||||
ORDER BY [pos].[POS_name]
|
||||
;
|
||||
|
||||
SELECT ActivePos_write.upd.DatabaseVersion() AS currentVersion;
|
||||
|
||||
SELECT SettingValue AS backupSrc
|
||||
FROM ActiveSystemServer.cfg.Settings
|
||||
WHERE SettingId LIKE 'Values.Modules.Replication.DbInitializationBackupPath%'
|
||||
AND LEN(SettingValue) > 1;
|
||||
|
||||
--last backup
|
||||
SELECT
|
||||
JobName = J.name,
|
||||
H.*
|
||||
FROM
|
||||
msdb.dbo.sysjobs AS J
|
||||
CROSS APPLY (
|
||||
SELECT TOP 20
|
||||
JobName = J.name,
|
||||
StepNumber = T.step_id,
|
||||
StepName = T.step_name,
|
||||
StepStatus = CASE T.run_status
|
||||
WHEN 0 THEN 'Failed'
|
||||
WHEN 1 THEN 'Succeeded'
|
||||
WHEN 2 THEN 'Retry'
|
||||
WHEN 3 THEN 'Canceled'
|
||||
ELSE 'Running' END,
|
||||
ExecutedAt = msdb.dbo.agent_datetime(T.run_date, T.run_time),
|
||||
ExecutingHours = ((T.run_duration/10000 * 3600 + (T.run_duration/100) % 100 * 60 + T.run_duration % 100 + 31 ) / 60) / 60,
|
||||
ExecutingMinutes = ((T.run_duration/10000 * 3600 + (T.run_duration/100) % 100 * 60 + T.run_duration % 100 + 31 ) / 60) % 60,
|
||||
Message = T.message
|
||||
,t.[instance_id]
|
||||
FROM msdb.dbo.sysjobhistory AS T
|
||||
WHERE T.job_id = J.job_id
|
||||
ORDER BY t.[instance_id] DESC
|
||||
) AS H
|
||||
WHERE [J].[name]='D91030 - Backup ActivePos_Read'
|
||||
AND [H].[StepNumber] = 0
|
||||
ORDER BY J.name
|
||||
|
||||
SELECT @@SERVERNAME
|
||||
RETURN
|
||||
|
||||
--start backup
|
||||
EXEC msdb.dbo.sp_start_job @job_name = N'D91030 - Backup ActivePos_Read' , @step_name = 'Purge old ActivePos_Read backups'
|
||||
|
||||
WAITFOR DELAY '00:00:05.000'
|
||||
|
||||
WHILE EXISTS(
|
||||
SELECT sj.name
|
||||
, sja.*
|
||||
FROM msdb.dbo.sysjobactivity AS sja
|
||||
INNER JOIN msdb.dbo.sysjobs AS sj ON sja.job_id = sj.job_id
|
||||
WHERE sj.[name]='D91030 - Backup ActivePos_Read'
|
||||
AND sja.start_execution_date IS NOT NULL
|
||||
AND sja.stop_execution_date IS NULL
|
||||
) BEGIN
|
||||
--PRINT 'job is still running '+CONVERT(VARCHAR(20), CURRENT_TIMESTAMP, 120);
|
||||
DECLARE @t VARCHAR(20) = CONVERT(VARCHAR(20), CURRENT_TIMESTAMP, 120);
|
||||
RAISERROR('%s, job is still running', 0, 1, @t) WITH NOWAIT;
|
||||
WAITFOR DELAY '00:00:05.000'
|
||||
END
|
||||
|
||||
--check POS and PHCY versions
|
||||
SELECT ActivePos_write.upd.DatabaseVersion() AS currentVersion
|
||||
EXEC ('SELECT ActivePos_write.upd.DatabaseVersion()') AT xxx
|
||||
|
||||
--force restore after manual copy
|
||||
EXEC ('exec ActivePos_write.dbo.InitializeActivePosReadFromBackup @BackUpFileWithPath = ''c:\temp\ActivePos_read.22.1.223.2401.bak''') AT xxx
|
||||
|
||||
--to start on the pos to force a restore of the backup. adapt version, mac and UNC before running
|
||||
exec ActiveSystemClient.dbo.DBAReplPosSubscription
|
||||
@mac = '9C-7B-EF-43-5A-98',
|
||||
@serverDbVersion = '23.2.23.19501',
|
||||
@preferedReplinibackup= '\\cvi247aps-replinibackup.coop-vitality.ch\replinibackup\ActivePos_read.23.2.23.19501.bak'
|
||||
|
||||
|
||||
--restart service on pos
|
||||
EXEC ('EXEC xp_cmdshell ''net stop ActiveposClientService'';EXEC xp_cmdshell ''net start ActiveposClientService''') AT xxx
|
||||
|
||||
--subscription
|
||||
EXEC ActivePos_read..sp_dropsubscription @publication = N'ActivePosTran', @article = N'all', @subscriber ='xxx'
|
||||
EXEC ActiveSystemServer.dbo.RepairReplication
|
||||
@@ -0,0 +1,10 @@
|
||||
USE master
|
||||
GO
|
||||
|
||||
--EXEC ('exec ActivePos_write.dbo.InitializeActivePosReadFromBackup @BackUpFileWithPath = ''c:\temp\ActivePos_read.23.4.23.28503.bak''')
|
||||
RESTORE DATABASE ActivePos_read
|
||||
FROM DISK = 'c:\temp\ActivePos_read.23.4.23.28503.bak'
|
||||
WITH MOVE N'ActivePos_read_Data'
|
||||
TO 'C:\SQLDataBase\Data\ActivePos_Read.mdf',
|
||||
MOVE N'ActivePos_read_Log'
|
||||
TO 'C:\SQLDataBase\Log\ActivePos_Read.ldf', STATS = 10, REPLACE
|
||||
@@ -0,0 +1,51 @@
|
||||
USE [ActivePos_read]
|
||||
|
||||
/*
|
||||
IF OBJECT_ID('dbo.zz_customer')IS NOT NULL BEGIN;
|
||||
DROP TABLE dbo.zz_customer;
|
||||
END;
|
||||
|
||||
SELECT [c].[CustomerId], [c].[CustomerCentralRemark]
|
||||
INTO hcitools.tmp.zz_customer
|
||||
FROM [dbo].[IIICustomer] c
|
||||
*/
|
||||
|
||||
------- test 1, update en masse
|
||||
--UPDATE [dbo].[IIICustomer]
|
||||
--SET [CustomerCentralRemark] = 'test repli'
|
||||
--WHERE 1=1
|
||||
|
||||
------- test 2, update de tous les clients, 1 ligne par transaction
|
||||
DECLARE @cid INT
|
||||
|
||||
DECLARE crsr_cust CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [s].[CustomerId]
|
||||
FROM hcitools.tmp.zz_customer s
|
||||
JOIN [dbo].[IIICustomer] t ON t.[CustomerId] = s.[CustomerId]
|
||||
OPEN crsr_cust
|
||||
|
||||
FETCH NEXT FROM crsr_cust INTO @cid
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
BEGIN TRANSACTION
|
||||
UPDATE [dbo].[IIICustomer]
|
||||
SET [CustomerCentralRemark] = 'test perf 2'
|
||||
WHERE [CustomerId] = @cid;
|
||||
COMMIT TRANSACTION
|
||||
|
||||
FETCH NEXT FROM crsr_cust INTO @cid
|
||||
END
|
||||
|
||||
CLOSE crsr_cust
|
||||
DEALLOCATE crsr_cust
|
||||
|
||||
|
||||
------ test 3, restore les commentaires initiaux
|
||||
UPDATE t SET [t].[CustomerCentralRemark] = s.[CustomerCentralRemark]
|
||||
FROM hcitools.tmp.zz_customer s
|
||||
JOIN [dbo].[IIICustomer] t ON t.[CustomerId] = s.[CustomerId]
|
||||
WHERE ISNULL(s.[CustomerCentralRemark],'') <> ISNULL(t.[CustomerCentralRemark],'')
|
||||
|
||||
|
||||
SELECT COUNT(1) FROM [zz_customer]
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
IF OBJECT_ID('dbo.zz_IIIPartner_Item_Details')IS NOT NULL BEGIN;
|
||||
DROP TABLE dbo.zz_IIIPartner_Item_Details;
|
||||
END;
|
||||
|
||||
SELECT *
|
||||
INTO hcitools.tmp.zz_IIIPartner_Item_Details
|
||||
FROM [dbo].[IIIPartner_Item_Details]
|
||||
*/
|
||||
|
||||
-- test 1, update form_11
|
||||
UPDATE t SET [t].[Form_11] = 'test repli'
|
||||
FROM hcitools.tmp.zz_IIIPartner_Item_Details s
|
||||
JOIN [dbo].[IIIPartner_Item_Details] t ON s.[Item_Id] = t.[Item_Id]
|
||||
WHERE 1=1
|
||||
|
||||
-- revert test 1
|
||||
UPDATE t SET [t].[Form_11] = s.[Form_11]
|
||||
FROM hcitools.tmp.zz_IIIPartner_Item_Details s
|
||||
JOIN [dbo].[IIIPartner_Item_Details] t ON s.[Item_Id] = t.[Item_Id]
|
||||
WHERE ISNULL(t.[Form_11],'') <> ISNULL(s.[Form_11],'')
|
||||
1961
PULL replication perf validation/init on POS log.txt
Normal file
1961
PULL replication perf validation/init on POS log.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user