
IF OBJECT_ID('tempdb..#pos')IS NOT NULL BEGIN;
	DROP TABLE #pos;
END;

SELECT pos.POS_hostname
INTO #pos
FROM [Arizona].[dbo].[Point_of_sale] [pos]
WHERE [pos].[POS_active]=1
AND [pos].[POS_type] IN (1,2)
AND [pos].[POS_number] < 99

;

DECLARE @qry NVARCHAR(MAX)='';
SELECT @qry = @qry + 'exec ActivePos_read..sp_dropsubscription @publication = N''ActivePosTran'', @article = N''all'', @subscriber ='''+POS_hostname+''';
'
FROM #pos;

EXEC(@qry)
EXEC ActiveSystemServer.dbo.RepairReplication

