added files from swmgmt03

This commit is contained in:
Schork Thierry (Galenica - ADM)
2025-09-22 09:00:00 +02:00
parent de97031b1e
commit 63d058a7eb
67 changed files with 13300 additions and 1 deletions

86
repl.sql Normal file
View File

@@ -0,0 +1,86 @@
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_number]
;
SELECT SettingValue AS backupSrc, SettingId
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
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()')
--restart service on pos
EXEC ('EXEC xp_cmdshell ''net stop ActiveposClientService'';EXEC xp_cmdshell ''net start ActiveposClientService''')
exec xp_cmdshell 'net stop ActiveposClientService'
exec xp_cmdshell 'net start ActiveposClientService'
--subscription
EXEC ActivePos_read..sp_dropsubscription @publication = N'ActivePosTran', @article = N'all', @subscriber ='xxx'
select *
--delete s
from distribution.dbo.MSsubscriber_schedule s
where subscriber='xxxx'
EXEC ActiveSystemServer.dbo.RepairReplication