Merge branch 'main' of https://github.com/tschork/sql-scripts
This commit is contained in:
72
CENT - reseed pharmindexTP identity.sql
Normal file
72
CENT - reseed pharmindexTP identity.sql
Normal file
@@ -0,0 +1,72 @@
|
||||
use PharmIndexTP
|
||||
|
||||
|
||||
DECLARE @TableName NVARCHAR(255);
|
||||
DECLARE @IdentityColumn NVARCHAR(255);
|
||||
declare @currentIdentityValue int;
|
||||
DECLARE @MaxIdentityValue INT;
|
||||
DECLARE @SQL NVARCHAR(MAX);
|
||||
declare @reseedSQL nvarchar(max)='';
|
||||
|
||||
-- Create a table variable to hold the list of tables
|
||||
DECLARE @Tables TABLE (TableName NVARCHAR(255));
|
||||
|
||||
-- Insert the tables into the table variable
|
||||
INSERT INTO @Tables (TableName)
|
||||
VALUES
|
||||
('ServiceProvider'),
|
||||
('ServiceProviderAddress'),
|
||||
('ServiceProviderCommunication'),
|
||||
('ServiceProviderCommunication2'),
|
||||
('ServiceProviderECommunication'),
|
||||
('ServiceProviderECommunication2'),
|
||||
('ServiceProviderReference'),
|
||||
('ServiceProviderRole')
|
||||
|
||||
-- Cursor to iterate over the list of tables
|
||||
DECLARE TableCursor CURSOR FOR
|
||||
SELECT TableName
|
||||
FROM @Tables;
|
||||
|
||||
OPEN TableCursor;
|
||||
FETCH NEXT FROM TableCursor INTO @TableName;
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
-- Get the primary key column name which is assumed to be the identity column
|
||||
SELECT @IdentityColumn = [KU].[COLUMN_NAME]
|
||||
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
|
||||
JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE KU
|
||||
ON TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME
|
||||
WHERE TC.TABLE_NAME = @TableName
|
||||
AND TC.CONSTRAINT_TYPE = 'PRIMARY KEY';
|
||||
|
||||
-- Get the maximum identity value for the current table
|
||||
SET @SQL = 'SELECT @MaxIdentityValue = MAX(' + @IdentityColumn + ') FROM ' + @TableName;
|
||||
EXEC sp_executesql @SQL, N'@MaxIdentityValue INT OUTPUT', @MaxIdentityValue OUTPUT;
|
||||
--print 'max value fetched'
|
||||
|
||||
--fetch current identity value
|
||||
set @sql = 'SELECT @currentIdentityValue=IDENT_CURRENT('''+@tableName+''') ';
|
||||
exec sp_executesql @sql, N'@currentIdentityValue INT OUTPUT', @currentIdentityValue OUTPUT;
|
||||
--print 'identity value fetched'
|
||||
|
||||
print 'table: "'+@tableName+'", column "'+@IdentityColumn+'"
|
||||
current column max value: '+cast(@MaxIdentityValue as varchar(50))+'
|
||||
identity value: '+cast(@currentIdentityValue as varchar(50));
|
||||
|
||||
-- Reseed the identity column
|
||||
if @currentIdentityValue < @MaxIdentityValue
|
||||
begin
|
||||
SET @SQL = 'DBCC CHECKIDENT (''' + @TableName + ''', RESEED, ' + CAST(ISNULL(@MaxIdentityValue, 0) AS NVARCHAR) + ')';
|
||||
--EXEC sp_executesql @SQL;
|
||||
set @reseedSQL = @reseedSQL+char(13)+char(10)+@sql
|
||||
end
|
||||
|
||||
FETCH NEXT FROM TableCursor INTO @TableName;
|
||||
END
|
||||
|
||||
print @reseedSQL;
|
||||
|
||||
CLOSE TableCursor;
|
||||
DEALLOCATE TableCursor;
|
||||
82
Calculate waits over a time period.sql
Normal file
82
Calculate waits over a time period.sql
Normal file
@@ -0,0 +1,82 @@
|
||||
/* Snapshot the current wait stats and store so that this can be compared over a time period
|
||||
Return the statistics between this point in time and the last collection point in time.
|
||||
|
||||
**This data is maintained in tempdb so the connection must persist between each execution**
|
||||
**alternatively this could be modified to use a persisted table in tempdb. if that
|
||||
is changed code should be included to clean up the table at some point.**
|
||||
*/
|
||||
USE tempdb;
|
||||
GO
|
||||
|
||||
DECLARE @current_snap_time AS DATETIME;
|
||||
DECLARE @previous_snap_time AS DATETIME;
|
||||
|
||||
SET @current_snap_time = GETDATE();
|
||||
|
||||
IF NOT EXISTS (SELECT name
|
||||
FROM tempdb.sys.sysobjects
|
||||
WHERE name LIKE '#_wait_stats%')
|
||||
CREATE TABLE #_wait_stats
|
||||
(
|
||||
wait_type VARCHAR (128),
|
||||
waiting_tasks_count BIGINT,
|
||||
wait_time_ms BIGINT,
|
||||
avg_wait_time_ms INT,
|
||||
max_wait_time_ms BIGINT,
|
||||
signal_wait_time_ms BIGINT,
|
||||
avg_signal_wait_time INT,
|
||||
snap_time DATETIME
|
||||
);
|
||||
|
||||
INSERT INTO #_wait_stats (wait_type, waiting_tasks_count, wait_time_ms, max_wait_time_ms, signal_wait_time_ms, snap_time)
|
||||
SELECT wait_type,
|
||||
waiting_tasks_count,
|
||||
wait_time_ms,
|
||||
max_wait_time_ms,
|
||||
signal_wait_time_ms,
|
||||
getdate()
|
||||
FROM sys.dm_os_wait_stats;
|
||||
|
||||
--get the previous collection point
|
||||
SELECT TOP 1 @previous_snap_time = snap_time
|
||||
FROM #_wait_stats
|
||||
WHERE snap_time < (SELECT MAX(snap_time)
|
||||
FROM #_wait_stats)
|
||||
ORDER BY snap_time DESC;
|
||||
|
||||
--get delta in the wait stats
|
||||
SELECT TOP 10 s.wait_type,
|
||||
(e.waiting_tasks_count - s.waiting_tasks_count) AS [waiting_tasks_count],
|
||||
(e.wait_time_ms - s.wait_time_ms) AS [wait_time_ms],
|
||||
(e.wait_time_ms - s.wait_time_ms) / ((e.waiting_tasks_count - s.waiting_tasks_count)) AS [avg_wait_time_ms],
|
||||
(e.max_wait_time_ms) AS [max_wait_time_ms],
|
||||
(e.signal_wait_time_ms - s.signal_wait_time_ms) AS [signal_wait_time_ms],
|
||||
(e.signal_wait_time_ms - s.signal_wait_time_ms) / ((e.waiting_tasks_count - s.waiting_tasks_count)) AS [avg_signal_time_ms],
|
||||
s.snap_time AS [start_time],
|
||||
e.snap_time AS [end_time],
|
||||
DATEDIFF(ss, s.snap_time, e.snap_time) AS [seconds_in_sample]
|
||||
FROM #_wait_stats AS e
|
||||
INNER JOIN (SELECT *
|
||||
FROM #_wait_stats
|
||||
WHERE snap_time = @previous_snap_time) AS s
|
||||
ON (s.wait_type = e.wait_type)
|
||||
WHERE e.snap_time = @current_snap_time
|
||||
AND s.snap_time = @previous_snap_time
|
||||
AND e.wait_time_ms > 0
|
||||
AND (e.waiting_tasks_count - s.waiting_tasks_count) > 0
|
||||
AND e.wait_type NOT IN ('LAZYWRITER_SLEEP', 'SQLTRACE_BUFFER_FLUSH', 'SOS_SCHEDULER_YIELD',
|
||||
'DBMIRRORING_CMD', 'BROKER_TASK_STOP', 'CLR_AUTO_EVENT',
|
||||
'BROKER_RECEIVE_WAITFOR', 'WAITFOR', 'SLEEP_TASK',
|
||||
'REQUEST_FOR_DEADLOCK_SEARCH', 'XE_TIMER_EVENT',
|
||||
'FT_IFTS_SCHEDULER_IDLE_WAIT', 'BROKER_TO_FLUSH',
|
||||
'XE_DISPATCHER_WAIT', 'SQLTRACE_INCREMENTAL_FLUSH_SLEEP'
|
||||
|
||||
--list of filtered out waits from Paul Randall
|
||||
,'HADR_FILESTREAM_IOMGR_IOCOMPLETION','SOS_WORK_DISPATCHER','SP_SERVER_DIAGNOSTICS_SLEEP'
|
||||
,'LOGMGR_QUEUE','DISPATCHER_QUEUE_SEMAPHORE','CHECKPOINT_QUEUE','DIRTY_PAGE_POLL'
|
||||
,'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP')
|
||||
ORDER BY (e.wait_time_ms - s.wait_time_ms) DESC;
|
||||
|
||||
--clean up table
|
||||
DELETE FROM #_wait_stats
|
||||
WHERE snap_time = @previous_snap_time;
|
||||
49
DBG - change dump device for arizona to u drive.sql
Normal file
49
DBG - change dump device for arizona to u drive.sql
Normal file
@@ -0,0 +1,49 @@
|
||||
if object_id('tempdb..#drives') is not null
|
||||
drop table #drives
|
||||
|
||||
create table #drives(stdout varchar(255));
|
||||
|
||||
insert into #drives
|
||||
exec xp_cmdshell 'dir u:'
|
||||
|
||||
--select * from #drives where stdout is not null
|
||||
if (select count(1) from #drives where stdout is not null) > 2
|
||||
begin
|
||||
print 'drive U exists';
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM [sys].[backup_devices]
|
||||
WHERE name='Arizona_Dump' AND [physical_name] LIKE 'D:%'
|
||||
)
|
||||
BEGIN
|
||||
EXEC [sys].[sp_dropdevice] @logicalname = 'Arizona_Dump',@delfile = NULL;
|
||||
PRINT 'Dump device Arizona_Dump removed';
|
||||
END
|
||||
IF NOT EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_Dump')
|
||||
BEGIN
|
||||
EXEC master.dbo.sp_addumpdevice @devtype = N'disk',
|
||||
@logicalname = N'Arizona_Dump',
|
||||
@physicalname = N'U:\Arizona_Dump.bak';
|
||||
PRINT 'Dump device Arizona_Dump created on U drive';
|
||||
END
|
||||
IF EXISTS (SELECT * FROM [sys].[backup_devices] WHERE name='Arizona_dump_SECU' AND [physical_name] LIKE 'D:%')
|
||||
BEGIN
|
||||
EXEC [sys].[sp_dropdevice] @logicalname = 'Arizona_dump_SECU',@delfile = NULL
|
||||
PRINT 'Dump device Arizona_dump_SECU removed';
|
||||
END
|
||||
IF NOT EXISTS (SELECT 1 FROM [sys].[backup_devices] WHERE name='Arizona_dump_SECU')
|
||||
BEGIN
|
||||
EXEC master.dbo.sp_addumpdevice @devtype = N'disk',
|
||||
@logicalname = N'Arizona_dump_SECU',
|
||||
@physicalname = N'U:\Arizona_dump_SECU.bak';
|
||||
PRINT 'Dump device Arizona_dump_SECU created on U drive';
|
||||
END
|
||||
end
|
||||
else
|
||||
begin
|
||||
print 'drive U does not exists'
|
||||
end
|
||||
|
||||
if object_id('tempdb..#drives') is not null
|
||||
drop table #drives
|
||||
|
||||
8
DBG - check snapshot isloation.sql
Normal file
8
DBG - check snapshot isloation.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
USE master;
|
||||
GO
|
||||
|
||||
SELECT
|
||||
name AS DatabaseName,
|
||||
snapshot_isolation_state_desc AS SnapshotIsolationState,
|
||||
is_read_committed_snapshot_on AS IsReadCommittedSnapshotOn
|
||||
FROM sys.databases
|
||||
62
DBG - clean orphaned users.sql
Normal file
62
DBG - clean orphaned users.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
declare @cmd varchar(8000),
|
||||
@name varchar (255)
|
||||
|
||||
USE master
|
||||
|
||||
SET NOCOUNT ON
|
||||
|
||||
declare c_databases cursor local forward_only static for
|
||||
SELECT name
|
||||
FROM sys.databases
|
||||
WHERE name not in ('master','msdb','tempDB','model','SSISDB')
|
||||
AND [is_read_only] = 0
|
||||
AND [state_desc] = 'ONLINE'
|
||||
ORDER BY name
|
||||
;
|
||||
open c_databases
|
||||
;
|
||||
FETCH NEXT FROM c_databases
|
||||
into @name
|
||||
;
|
||||
while @@fetch_status = 0
|
||||
begin
|
||||
SET @cmd = 'declare @name varchar(50)
|
||||
|
||||
declare c_users cursor local forward_only static for
|
||||
SELECT dp.name
|
||||
FROM '+@name+'.sys.database_principals AS dp
|
||||
LEFT JOIN '+@name+'.sys.server_principals AS sp
|
||||
ON dp.SID = sp.SID
|
||||
WHERE sp.SID IS NULL
|
||||
AND dp.type_desc = ''SQL_USER''
|
||||
AND dp.principal_id > 4;
|
||||
|
||||
open c_users
|
||||
|
||||
FETCH NEXT FROM c_users
|
||||
into @name
|
||||
|
||||
while @@fetch_status = 0
|
||||
begin
|
||||
|
||||
print''USE ['+@name+']; DROP USER [''+@name+'']''
|
||||
--EXEC (''USE ['+@name+']; DROP USER [''+@name+'']'')
|
||||
|
||||
FETCH NEXT FROM c_users
|
||||
into @name
|
||||
|
||||
end
|
||||
close c_users
|
||||
deallocate c_users
|
||||
' /* #fla01 */
|
||||
|
||||
exec (@cmd)
|
||||
|
||||
FETCH NEXT FROM c_databases
|
||||
into @name
|
||||
;
|
||||
end
|
||||
;
|
||||
close c_databases
|
||||
;
|
||||
deallocate c_databases
|
||||
30
DBG - find orphaned replication meta data.sql
Normal file
30
DBG - find orphaned replication meta data.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
USE [distribution]
|
||||
|
||||
SELECT *
|
||||
--delete
|
||||
FROM MSsubscriptions
|
||||
|
||||
|
||||
SELECT *
|
||||
--delete
|
||||
FROM MSsubscriber_info
|
||||
where subscriber like '%T09'
|
||||
|
||||
SELECT *
|
||||
--delete
|
||||
FROM MSpublications
|
||||
|
||||
|
||||
SELECT *
|
||||
FROM MSdistribution_agents
|
||||
--where name like '%31'
|
||||
|
||||
SELECT *
|
||||
--delete
|
||||
FROM MSsubscriber_schedule
|
||||
where subscriber like '%T02'
|
||||
|
||||
|
||||
SELECT *
|
||||
--delete
|
||||
FROM MSdistribution_history
|
||||
41
DBG - generate disable change tracking cmds.sql
Normal file
41
DBG - generate disable change tracking cmds.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
use Arizona_delphix
|
||||
|
||||
-- 'ALTER TABLE ' + @schema + '.' + @tableName + ' DISABLE CHANGE_TRACKING;'
|
||||
SELECT 'Arizona' as Database_name, s.name AS Schema_name, t.name AS Table_name , 'ALTER TABLE ' + s.name + '.' + t.name + ' DISABLE CHANGE_TRACKING;'
|
||||
FROM Arizona_delphix.sys.change_tracking_tables ctt
|
||||
JOIN Arizona_delphix.sys.tables t
|
||||
ON t.object_id = ctt.object_id
|
||||
JOIN Arizona_delphix.sys.schemas s
|
||||
ON s.schema_id = t.schema_id
|
||||
--WHERE s.name = 'dbo'
|
||||
ORDER BY s.name, t.name;
|
||||
|
||||
return
|
||||
|
||||
|
||||
ALTER TABLE AP.WebShopStatusQueue DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.DL_posology DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Document_header DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Document_line DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Document_line_link DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Item_inventory DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Item_quantity DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Item_seasonal_stock_info DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Item_standard_cost DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.LORE_item_ABC_code DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.LORE_supplying_procedure DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.PH_insurance_card DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.PH_insurance_plan DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.PH_insurance_recommendation DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.PH_patient DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.PH_prescription_header DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.PH_prescription_line DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE dbo.Price_modifier DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.DocumentSignature DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.GoodsReceipt DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.GoodsReceiptLine DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.MissedSale DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.OrderRequest DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.OrderRequestLine DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.PurchaseReturn DISABLE CHANGE_TRACKING;
|
||||
ALTER TABLE wkl.PurchaseReturnLine DISABLE CHANGE_TRACKING;
|
||||
@@ -21,7 +21,6 @@ SELECT t.name AS TableName,
|
||||
WHERE i.object_id > 255
|
||||
-- AND i.index_id IN ( 0, 1 ) --0=heap, 1= clustered
|
||||
AND t.name NOT LIKE 'dt%'
|
||||
AND t.name LIKE '%'
|
||||
AND [t].[is_ms_shipped] = 0
|
||||
AND i.object_id > 255
|
||||
GROUP BY t.name,
|
||||
|
||||
17
DBG - get compatibility mode of all db's.sql
Normal file
17
DBG - get compatibility mode of all db's.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
DECLARE @vers VARCHAR(20);
|
||||
SELECT @vers=CAST(SERVERPROPERTY('productversion') AS VARCHAR(20));
|
||||
IF @vers LIKE '16.%'
|
||||
BEGIN
|
||||
SELECT COUNT(1) AS db_count
|
||||
, compatibility_level
|
||||
, MAX(STUFF(CONVERT(VARCHAR(MAX), x.[db_Lst]),1,1,'')) AS lst
|
||||
FROM sys.databases d
|
||||
OUTER APPLY (
|
||||
SELECT ','+name
|
||||
FROM sys.databases dd
|
||||
WHERE dd.compatibility_level = d.compatibility_level
|
||||
FOR XML PATH('')
|
||||
)x(db_Lst)
|
||||
WHERE d.compatibility_level <> 160 -- 160=SQL2022
|
||||
GROUP BY compatibility_level
|
||||
END
|
||||
23
DBG - get list of sp in execution cache.sql
Normal file
23
DBG - get list of sp in execution cache.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
use arizona
|
||||
|
||||
SELECT p.name, max(ps.last_execution_time) last_time
|
||||
FROM sys.dm_exec_procedure_stats ps
|
||||
JOIN sys.procedures AS p ON (ps.object_id = p.object_id)
|
||||
GROUP BY p.name
|
||||
|
||||
|
||||
SELECT
|
||||
DB_NAME(database_id) AS database_name,
|
||||
OBJECT_NAME(object_id, database_id) AS object_name,
|
||||
cached_time,
|
||||
last_execution_time,
|
||||
execution_count,
|
||||
total_elapsed_time,
|
||||
total_worker_time
|
||||
FROM
|
||||
sys.dm_exec_procedure_stats
|
||||
WHERE
|
||||
OBJECT_NAME(object_id, database_id) IS NOT NULL
|
||||
and DB_NAME(database_id) = 'arizona'
|
||||
ORDER BY
|
||||
last_execution_time DESC;
|
||||
Binary file not shown.
339
DBG - script job(s).sql
Normal file
339
DBG - script job(s).sql
Normal file
@@ -0,0 +1,339 @@
|
||||
/* SYSJOBS */
|
||||
DECLARE @job_id UNIQUEIDENTIFIER = NULL,
|
||||
@name NVARCHAR(128) = NULL,
|
||||
@enabled TINYINT = 1,
|
||||
@description NVARCHAR(512) = NULL,
|
||||
@start_step_id INT = 1,
|
||||
@category_id INT,
|
||||
@owner_sid VARBINARY(85) = NULL,
|
||||
@notify_level_eventlog INT = 0,
|
||||
@notify_level_email INT = 0,
|
||||
@notify_level_netsend INT = 0,
|
||||
@notify_level_page INT = 0,
|
||||
@delete_level INT = 0,
|
||||
@categoryname NVARCHAR(128) = NULL,
|
||||
@categorytype VARCHAR(12) = NULL,
|
||||
@categoryclass INT,
|
||||
@loginname NVARCHAR(128) = NULL,
|
||||
/* NOT USED FOR NOW */
|
||||
@notify_email_operator_id INT = 0,
|
||||
@notify_netsend_operator_id INT = 0,
|
||||
@notify_page_operator_id INT = 0,
|
||||
/* SYSJOBSTEP */
|
||||
@step_id INT = NULL,
|
||||
@step_name NVARCHAR(128),
|
||||
@subsystem NVARCHAR(40),
|
||||
@command NVARCHAR(MAX) = NULL,
|
||||
@flags INT,
|
||||
@additional_parameters NVARCHAR(MAX) = NULL,
|
||||
@cmdexec_success_code INT = 0,
|
||||
@on_success_action TINYINT,
|
||||
@on_success_step_id INT = 0,
|
||||
@on_fail_action TINYINT,
|
||||
@on_fail_step_id INT = 0,
|
||||
@server NVARCHAR(128) = NULL,
|
||||
@database_name NVARCHAR(128) = NULL,
|
||||
@database_user_name NVARCHAR(128) = NULL,
|
||||
@retry_attempts INT = 0,
|
||||
@retry_interval INT = 0,
|
||||
@os_run_priority INT,
|
||||
@output_file_name NVARCHAR(200) = NULL,
|
||||
@last_run_outcome INT,
|
||||
@last_run_duration INT,
|
||||
@last_run_retries INT,
|
||||
@last_run_date INT,
|
||||
@last_run_time INT,
|
||||
@proxy_id INT = NULL,
|
||||
@proxyname NVARCHAR(128) = NULL,
|
||||
@cmd VARCHAR(MAX),
|
||||
@path VARCHAR(200),
|
||||
/* SYSSCHEDULES */
|
||||
@freq_type INT,
|
||||
@freq_interval INT,
|
||||
@freq_subday_type INT,
|
||||
@freq_subday_interval INT,
|
||||
@freq_relative_interval INT,
|
||||
@freq_recurrence_factor INT,
|
||||
@active_start_date INT,
|
||||
@active_end_date INT,
|
||||
@active_start_time INT,
|
||||
@active_end_time INT,
|
||||
/* CUSTOM */
|
||||
@code_job NVARCHAR(10) = NULL
|
||||
|
||||
DECLARE c_jobs CURSOR LOCAL FORWARD_ONLY STATIC FOR
|
||||
SELECT sj.job_id,sj.name, sj.[enabled], sj.[description], sj.start_step_id, sj.category_id, sj.owner_sid, sj.notify_level_eventlog, sj.notify_level_email, sj.notify_level_netsend, sj.notify_level_page, sj.notify_email_operator_id, sj.notify_netsend_operator_id, sj.notify_page_operator_id, sj.delete_level
|
||||
FROM msdb.dbo.sysjobs sj
|
||||
JOIN msdb.dbo.[syscategories] sc ON sc.[category_id] = sj.[category_id]
|
||||
WHERE 1=1
|
||||
AND LOWER(sj.name) NOT LIKE '%distribution%'
|
||||
AND LOWER(sj.name) NOT LIKE '%subscription%'
|
||||
AND LOWER(sj.name) NOT LIKE '%replication%'
|
||||
AND LOWER(sj.name) NOT LIKE '%ActivePos_read-%'
|
||||
AND sj.name LIKE '%-%'
|
||||
AND sc.[name] NOT LIKE '%REPL%'
|
||||
--and sj.name = 'ZZ - TSC - TPDT-676 - connectivity check to POS'
|
||||
ORDER BY sj.name
|
||||
|
||||
|
||||
OPEN c_jobs
|
||||
|
||||
FETCH NEXT FROM c_jobs
|
||||
INTO @job_id, @name, @enabled, @description, @start_step_id, @category_id, @owner_sid, @notify_level_eventlog, @notify_level_email, @notify_level_netsend, @notify_level_page, @notify_email_operator_id, @notify_netsend_operator_id, @notify_page_operator_id, @delete_level
|
||||
|
||||
WHILE @@fetch_status = 0
|
||||
BEGIN
|
||||
|
||||
SET @path = 'd:\jobs\'+@name+'.sql'
|
||||
|
||||
--DECLARE @cleanCmd VARCHAR(8000)= 'del "'+@path+'"';
|
||||
--DECLARE @catchOutput TABLE(output VARCHAR(max));
|
||||
|
||||
--INSERT INTO @catchOutput ([output])
|
||||
--EXEC [sys].[xp_cmdshell] @cleanCmd;
|
||||
|
||||
EXEC HCITools.dbo.aps_File_Delete @path = @path; -- nvarchar(max)
|
||||
|
||||
|
||||
SET @code_job = SUBSTRING(@name,0,CHARINDEX('-',@name,0)-1)
|
||||
|
||||
SET @cmd = '/* Drop existing standard schedule for job */'+CHAR(13)+CHAR(10)+
|
||||
'declare @schedule_id int'+CHAR(13)+CHAR(10)+
|
||||
'declare c_schedules cursor local forward_only static for'+CHAR(13)+CHAR(10)+
|
||||
' select ss.schedule_id'+CHAR(13)+CHAR(10)+
|
||||
' from msdb.dbo.sysjobschedules sjs'+CHAR(13)+CHAR(10)+
|
||||
'INNER JOIN msdb.dbo.sysschedules ss'+CHAR(13)+CHAR(10)+
|
||||
' ON sjs.schedule_id = ss.schedule_id'+CHAR(13)+CHAR(10)+
|
||||
' AND ss.name NOT LIKE ''%#SPEC#'''+CHAR(13)+CHAR(10)+
|
||||
'INNER JOIN msdb.dbo.sysjobs sj'+CHAR(13)+CHAR(10)+
|
||||
' ON sjs.job_id = sj.job_id'+CHAR(13)+CHAR(10)+
|
||||
' WHERE sj.name = N'''+REPLACE(@name,'''','''''')+''''+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'open c_schedules'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'FETCH NEXT FROM c_schedules into @schedule_id'+CHAR(13)+CHAR(10)+
|
||||
'while @@fetch_status = 0'+CHAR(13)+CHAR(10)+
|
||||
'begin'+CHAR(13)+CHAR(10)+
|
||||
' IF ((select COUNT(*) from msdb.dbo.sysjobschedules where schedule_id=@schedule_id) = 1)'+CHAR(13)+CHAR(10)+
|
||||
' EXEC msdb.dbo.sp_delete_schedule @schedule_id=@schedule_id, @force_delete = 1'+CHAR(13)+CHAR(10)+
|
||||
'FETCH NEXT FROM c_schedules into @schedule_id'+CHAR(13)+CHAR(10)+
|
||||
'end'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'close c_schedules'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'deallocate c_schedules'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'IF EXISTS (SELECT job_id FROM msdb.dbo.sysjobs_view WHERE name = N'''+REPLACE(@name,'''','''''')+''')'+CHAR(13)+CHAR(10)+
|
||||
'EXEC msdb.dbo.sp_delete_job @job_name = N'''+REPLACE(@name,'''','''''')+''', @delete_unused_schedule=0'+CHAR(13)+CHAR(10)+
|
||||
'GO'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'/* Creation Job and Steps*/'+CHAR(13)+CHAR(10)+
|
||||
'BEGIN TRANSACTION'+CHAR(13)+CHAR(10)+
|
||||
'DECLARE @ReturnCode INT'+CHAR(13)+CHAR(10)+
|
||||
'SELECT @ReturnCode = 0'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
SET @categoryname = NULL
|
||||
SET @categoryclass = 1
|
||||
SET @categorytype = 'LOCAL'
|
||||
|
||||
SELECT @categoryname = name,@categoryclass = category_class, @categorytype = CASE category_type
|
||||
WHEN 1 THEN 'LOCAL'
|
||||
WHEN 2 THEN 'MULTI-SERVER'
|
||||
WHEN 3 THEN 'NONE' END
|
||||
FROM msdb.dbo.syscategories WHERE category_id = @category_id
|
||||
|
||||
SET @loginname = NULL
|
||||
|
||||
SELECT @loginname = name FROM sys.syslogins WHERE sid = @owner_sid
|
||||
|
||||
/*
|
||||
, @notify_level_eventlog =
|
||||
, @notify_level_email =
|
||||
, @notify_level_netsend =
|
||||
, @notify_level_page =
|
||||
, @notify_email_operator_name =
|
||||
, @notify_netsend_operator_name =
|
||||
, @notify_page_operator_name =
|
||||
|
||||
*/
|
||||
|
||||
|
||||
SET @cmd = 'IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'''+REPLACE(@categoryname,'''','''''')+''' AND category_class='+CAST(@categoryclass AS VARCHAR(1))+')'+CHAR(13)+CHAR(10)+
|
||||
'BEGIN'+CHAR(13)+CHAR(10)+
|
||||
'EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N''JOB'', @type=N'''+ @categorytype +''', @name=N'''+REPLACE(@categoryname,'''','''''')+''''+CHAR(13)+CHAR(10)+
|
||||
'IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'END'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'/* Add Job */'+CHAR(13)+CHAR(10)+
|
||||
'DECLARE @jobId BINARY(16)'+CHAR(13)+CHAR(10)+
|
||||
'EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'''+REPLACE(@name,'''','''''')+''', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@enabled=' +CAST(@enabled AS VARCHAR(1)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@notify_level_eventlog=' +CAST(@notify_level_eventlog AS VARCHAR(1)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@notify_level_email=' +CAST(@notify_level_email AS VARCHAR(1)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@notify_level_netsend=' +CAST(@notify_level_netsend AS VARCHAR(1)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@notify_level_page=' +CAST(@notify_level_page AS VARCHAR(1)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@delete_level='+CAST(@delete_level AS VARCHAR(2))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
SET @cmd = '@description='+ISNULL('N'''+REPLACE(@description,'''','''''')+'''','NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
SET @cmd = '@category_name=N'''+@categoryname+''', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@start_step_id='+CAST(@start_step_id AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@owner_login_name=N'''+@loginname+''', @job_id = @jobId OUTPUT'+CHAR(13)+CHAR(10)+
|
||||
'IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
DECLARE c_jobstep CURSOR LOCAL FORWARD_ONLY STATIC FOR
|
||||
SELECT step_id, step_name, subsystem, command, flags, additional_parameters, cmdexec_success_code, on_success_action, on_success_step_id, on_fail_action, on_fail_step_id, [server], database_name, database_user_name, retry_attempts, retry_interval, os_run_priority, output_file_name, last_run_outcome, proxy_id
|
||||
FROM msdb.dbo.sysjobsteps
|
||||
WHERE job_id = @job_id
|
||||
ORDER BY step_id
|
||||
|
||||
OPEN c_jobstep
|
||||
|
||||
FETCH NEXT FROM c_jobstep
|
||||
INTO @step_id, @step_name, @subsystem, @command, @flags, @additional_parameters, @cmdexec_success_code, @on_success_action, @on_success_step_id, @on_fail_action, @on_fail_step_id, @server, @database_name, @database_user_name, @retry_attempts, @retry_interval, @os_run_priority, @output_file_name, @last_run_outcome, @proxy_id
|
||||
|
||||
WHILE @@fetch_status = 0
|
||||
BEGIN
|
||||
|
||||
SET @proxyname = NULL
|
||||
|
||||
SELECT @proxyname = name FROM msdb.dbo.sysproxies WHERE proxy_id = @proxy_id
|
||||
|
||||
SET @cmd = '/* Add Step */'+CHAR(13)+CHAR(10)+
|
||||
'EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'''+REPLACE(@step_name,'''','''''')+''', '+CHAR(13)+CHAR(10)+CHAR(9)+ CHAR(9)+
|
||||
'@step_id='+CAST(@step_id AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@cmdexec_success_code='+CAST(@cmdexec_success_code AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@on_success_action='+CAST(@on_success_action AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@on_success_step_id='+CAST(@on_success_step_id AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@on_fail_action='+CAST(@on_fail_action AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@on_fail_step_id='+CAST(@on_fail_step_id AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@retry_attempts='+CAST(@retry_attempts AS VARCHAR(30))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@retry_interval='+CAST(@retry_interval AS VARCHAR(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@os_run_priority='+CAST(@os_run_priority AS VARCHAR(3))+', @subsystem=N'''+@subsystem+''', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
SET @cmd = '@command='+ISNULL('N'''+REPLACE(@command,'''','''''')+'''','NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
|
||||
SET @cmd = '@database_name='+ISNULL('N'''+@database_name+'''','NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@output_file_name='+ISNULL('N'''+@output_file_name+'''','NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@flags='+CAST(@flags as varchar(3))+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@database_user_name='+ISNULL('N'''+@database_user_name+'''','NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@server='+ISNULL('N'''+@server+'''','NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
SET @cmd = '@additional_parameters='+ISNULL('N'''+@additional_parameters+'''','NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
--'@proxy_id='+ISNULL(CAST(@proxy_id as varchar(50)),'NULL')+', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@proxy_id=NULL, '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@proxy_name='+ISNULL('N'''+@proxyname+'''','NULL')+''+CHAR(13)+CHAR(10)+
|
||||
'IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback'+CHAR(13)+CHAR(10)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
FETCH NEXT FROM c_jobstep
|
||||
into @step_id, @step_name, @subsystem, @command, @flags, @additional_parameters, @cmdexec_success_code, @on_success_action, @on_success_step_id, @on_fail_action, @on_fail_step_id, @server, @database_name, @database_user_name, @retry_attempts, @retry_interval, @os_run_priority, @output_file_name, @last_run_outcome, @proxy_id
|
||||
end
|
||||
|
||||
close c_jobstep
|
||||
|
||||
deallocate c_jobstep
|
||||
|
||||
SET @cmd = 'EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = '+CAST(@start_step_id as varchar(3))+CHAR(13)+CHAR(10)+
|
||||
'IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
declare c_schedules cursor local forward_only static for
|
||||
select name,[enabled],freq_type,freq_interval,freq_subday_type,freq_subday_interval,freq_relative_interval,freq_recurrence_factor,active_start_date,active_end_date,active_start_time,active_end_time
|
||||
from msdb.dbo.sysjobschedules sjs
|
||||
INNER JOIN msdb.dbo.sysschedules ss
|
||||
ON sjs.job_id = @job_id
|
||||
AND sjs.schedule_id = ss.schedule_id
|
||||
AND ss.name NOT LIKE '%#SPEC#'
|
||||
AND ss.name LIKE @code_job+'%'
|
||||
|
||||
open c_schedules
|
||||
|
||||
FETCH NEXT FROM c_schedules
|
||||
into @name,@enabled, @freq_type, @freq_interval, @freq_subday_type, @freq_subday_interval, @freq_relative_interval, @freq_recurrence_factor, @active_start_date, @active_end_date, @active_start_time, @active_end_time
|
||||
|
||||
while @@fetch_status = 0
|
||||
begin
|
||||
|
||||
SET @cmd = '/* Add Standard Schedule */'+CHAR(13)+CHAR(10)+
|
||||
'EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'''+REPLACE(@name,'''','''''')+''', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@enabled=' +CAST(@enabled as varchar(1)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@freq_type=' +CAST(@freq_type as varchar(3)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@freq_interval=' +CAST(@freq_interval as varchar(3)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@freq_subday_type=' +CAST(@freq_subday_type as varchar(1)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@freq_subday_interval=' +CAST(@freq_subday_interval as varchar(2)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@freq_relative_interval=' +CAST(@freq_relative_interval as varchar(2)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@freq_recurrence_factor=' +CAST(@freq_recurrence_factor as varchar(2)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@active_start_date=' +CAST(@active_start_date as varchar(8)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@active_end_date=' +CAST(@active_end_date as varchar(8)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@active_start_time=' +CAST(@active_start_time as varchar(6)) +', '+CHAR(13)+CHAR(10)+CHAR(9)+CHAR(9)+
|
||||
'@active_end_time=' +CAST(@active_end_time as varchar(6)) +''+CHAR(13)+CHAR(10)+
|
||||
'IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
FETCH NEXT FROM c_schedules
|
||||
into @name,@enabled, @freq_type, @freq_interval, @freq_subday_type, @freq_subday_interval, @freq_relative_interval, @freq_recurrence_factor, @active_start_date, @active_end_date, @active_start_time, @active_end_time
|
||||
end
|
||||
|
||||
close c_schedules
|
||||
|
||||
deallocate c_schedules
|
||||
|
||||
SET @cmd = '/* Attach existing specific schedule for job */'+CHAR(13)+CHAR(10)+
|
||||
'declare @enabled_schedule int,'+CHAR(13)+CHAR(10)+
|
||||
' @schedule_name nvarchar(50)'+CHAR(13)+CHAR(10)+
|
||||
'declare c_schedules cursor local forward_only static for'+CHAR(13)+CHAR(10)+
|
||||
'select enabled, name'+CHAR(13)+CHAR(10)+
|
||||
' from msdb.dbo.sysschedules'+CHAR(13)+CHAR(10)+
|
||||
' where name LIKE '''+@code_job+'%'''+CHAR(13)+CHAR(10)+
|
||||
' and name LIKE ''%#SPEC#'''+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'open c_schedules'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'FETCH NEXT FROM c_schedules into @enabled_schedule, @schedule_name'+CHAR(13)+CHAR(10)+
|
||||
'while @@fetch_status = 0'+CHAR(13)+CHAR(10)+
|
||||
'begin'+CHAR(13)+CHAR(10)+
|
||||
' EXEC @ReturnCode = msdb.dbo.sp_attach_schedule @job_id = @jobId, @schedule_name=@schedule_name'+CHAR(13)+CHAR(10)+
|
||||
' IF(@enabled_schedule = 1)'+CHAR(13)+CHAR(10)+
|
||||
' begin'+CHAR(13)+CHAR(10)+
|
||||
' SET @schedule_name = SUBSTRING(@schedule_name,0,LEN(@schedule_name)-5)'+CHAR(13)+CHAR(10)+
|
||||
' IF EXISTS (select name from msdb.dbo.sysschedules where name = @schedule_name)'+CHAR(13)+CHAR(10)+
|
||||
' EXEC @ReturnCode = msdb.dbo.sp_update_schedule @name=@schedule_name, @enabled=0'+CHAR(13)+CHAR(10)+
|
||||
' end'+CHAR(13)+CHAR(10)+
|
||||
' IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback'+CHAR(13)+CHAR(10)+
|
||||
'FETCH NEXT FROM c_schedules into @enabled_schedule, @schedule_name'+CHAR(13)+CHAR(10)+
|
||||
'end'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'close c_schedules'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'deallocate c_schedules'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
SET @cmd = 'EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N''(local)'''+CHAR(13)+CHAR(10)+
|
||||
'IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback'+CHAR(13)+CHAR(10)+
|
||||
'COMMIT TRANSACTION'+CHAR(13)+CHAR(10)+
|
||||
'GOTO EndSave'+CHAR(13)+CHAR(10)+
|
||||
'QuitWithRollback:'+CHAR(13)+CHAR(10)+
|
||||
' IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION'+CHAR(13)+CHAR(10)+
|
||||
'EndSave:'+CHAR(13)+CHAR(10)+CHAR(13)+CHAR(10)+
|
||||
'GO'+CHAR(13)+CHAR(10)
|
||||
|
||||
|
||||
EXEC HCITools.[dbo].[aps_File_Write_Text] @data = @cmd, @path = @path,@append = 1, @encoding = 'utf-16'
|
||||
|
||||
FETCH NEXT FROM c_jobs
|
||||
into @job_id, @name, @enabled, @description, @start_step_id, @category_id, @owner_sid, @notify_level_eventlog, @notify_level_email, @notify_level_netsend, @notify_level_page, @notify_email_operator_id, @notify_netsend_operator_id, @notify_page_operator_id, @delete_level
|
||||
|
||||
end
|
||||
|
||||
close c_jobs
|
||||
|
||||
deallocate c_jobs
|
||||
16
DBG - suspect database.sql
Normal file
16
DBG - suspect database.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
adapt the db name and execute each of those steps manually
|
||||
|
||||
if data corruption have occured, restoring a backup might need necessary
|
||||
*/
|
||||
return
|
||||
|
||||
ALTER DATABASE activepos_read SET EMERGENCY;
|
||||
|
||||
dbcc checkdb('activepos_read') WITH ALL_ERRORMSGS, NO_INFOMSGS
|
||||
|
||||
ALTER DATABASE activepos_read SET single_user with rollback immediate;
|
||||
|
||||
dbcc checkdb ('activepos_read',repair_allow_data_loss)
|
||||
|
||||
ALTER DATABASE activepos_read SET multi_user with rollback immediate;
|
||||
272
DELPHIX - arizonaCust cleanup.sql
Normal file
272
DELPHIX - arizonaCust cleanup.sql
Normal file
@@ -0,0 +1,272 @@
|
||||
USE HCITools
|
||||
|
||||
IF NOT EXISTS(SELECT 1 FROM sys.[schemas] s WHERE s.[name]='delphix')
|
||||
BEGIN
|
||||
EXEC('CREATE SCHEMA [delphix]');
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('delphix.arizonaCust_cleanup') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE delphix.arizonaCust_cleanup;
|
||||
END
|
||||
GO
|
||||
|
||||
/*
|
||||
OC-945
|
||||
|
||||
This procedure is used by Delphix to delete every data in arizonaCust.
|
||||
As the schema is not unified through all the pharmacies, Delphix cannot be used.
|
||||
|
||||
We have received a confirmation from Gilles Balanche on the 15 of Mai 2024 that
|
||||
arizonaCust in N+1 and N+2 env are not used, and that data can be deleted.
|
||||
*/
|
||||
CREATE PROCEDURE delphix.arizonaCust_cleanup
|
||||
AS
|
||||
BEGIN
|
||||
--deletion of data in arizonaCust
|
||||
IF EXISTS(
|
||||
SELECT 1
|
||||
FROM [master].[cfg].[InstanceContext] c
|
||||
WHERE (
|
||||
[type] = 'VALI' --N+1
|
||||
OR [type] = 'DEVE' --N+2
|
||||
)
|
||||
)
|
||||
BEGIN
|
||||
DECLARE @tbl_name VARCHAR(111), @schema_name VARCHAR(11);
|
||||
DECLARE @tplTruncate VARCHAR(MAX), @query VARCHAR(MAX);
|
||||
SET @tplTruncate='
|
||||
BEGIN TRY
|
||||
TRUNCATE TABLE [arizonaCust].[@schema@].[@tbl@];
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
DELETE FROM [arizonaCust].[@schema@].[@tbl@];
|
||||
END CATCH
|
||||
|
||||
';
|
||||
|
||||
DECLARE csr_tbl CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name], s.[name] as [schema_name]
|
||||
FROM [ArizonaCUST].[sys].[tables] d
|
||||
INNER JOIN [ArizonaCUST].[sys].[schemas] s on s.[schema_id] = d.[schema_id]
|
||||
|
||||
OPEN csr_tbl
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @query = REPLACE(
|
||||
REPLACE(
|
||||
@tplTruncate
|
||||
,'@schema@'
|
||||
,@schema_name
|
||||
)
|
||||
,'@tbl@'
|
||||
,@tbl_name
|
||||
);
|
||||
|
||||
PRINT @query;
|
||||
EXEC(@query);
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
END
|
||||
|
||||
CLOSE csr_tbl
|
||||
DEALLOCATE csr_tbl
|
||||
|
||||
|
||||
END
|
||||
|
||||
END
|
||||
go
|
||||
|
||||
IF OBJECT_ID('delphix.hciTool_cleanup') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE delphix.hciTool_cleanup;
|
||||
END
|
||||
GO
|
||||
|
||||
/*
|
||||
OC-945
|
||||
|
||||
This procedure is used by Delphix to delete every data in the TMP schema of hciTools.
|
||||
As the schema is not unified through all the pharmacies, Delphix cannot be used.
|
||||
*/
|
||||
CREATE PROCEDURE delphix.hciTool_cleanup
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @tbl_name VARCHAR(111), @schema_name VARCHAR(11);
|
||||
DECLARE @tplTruncate VARCHAR(MAX), @query VARCHAR(MAX);
|
||||
SET @tplTruncate='
|
||||
BEGIN TRY
|
||||
TRUNCATE TABLE [hciTools].[@schema@].[@tbl@];
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
DELETE FROM [hciTools].[@schema@].[@tbl@];
|
||||
END CATCH
|
||||
|
||||
';
|
||||
|
||||
DECLARE csr_tbl CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name], s.[name] as [schema_name]
|
||||
FROM [HCITools].[sys].[tables] d
|
||||
INNER JOIN [HCITools].[sys].[schemas] s on s.[schema_id] = d.[schema_id]
|
||||
WHERE schema_name(d.schema_id)='TMP'
|
||||
|
||||
OPEN csr_tbl
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @query = REPLACE(
|
||||
REPLACE(
|
||||
@tplTruncate
|
||||
,'@schema@'
|
||||
,@schema_name
|
||||
)
|
||||
,'@tbl@'
|
||||
,@tbl_name
|
||||
);
|
||||
|
||||
PRINT @query;
|
||||
EXEC(@query);
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
END
|
||||
|
||||
CLOSE csr_tbl
|
||||
DEALLOCATE csr_tbl
|
||||
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('delphix.arizonaLD_cleanup') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE delphix.arizonaLD_cleanup;
|
||||
END
|
||||
GO
|
||||
|
||||
/*
|
||||
OC-945
|
||||
|
||||
This procedure is used by Delphix to delete every data in arizonaLD database.
|
||||
As the schema is not unified through all the pharmacies, Delphix cannot be used.
|
||||
*/
|
||||
CREATE PROCEDURE delphix.arizonaLD_cleanup
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @tbl_name VARCHAR(111), @schema_name VARCHAR(11);
|
||||
DECLARE @tplTruncate VARCHAR(MAX), @query VARCHAR(MAX);
|
||||
SET @tplTruncate='
|
||||
BEGIN TRY
|
||||
TRUNCATE TABLE [arizonaLD].[@schema@].[@tbl@];
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
DELETE FROM [arizonaLD].[@schema@].[@tbl@];
|
||||
END CATCH
|
||||
|
||||
';
|
||||
|
||||
DECLARE csr_tbl CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name], s.[name] as [schema_name]
|
||||
FROM [arizonaLD].[sys].[tables] d
|
||||
INNER JOIN [arizonaLD].[sys].[schemas] s on s.[schema_id] = d.[schema_id]
|
||||
|
||||
OPEN csr_tbl
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @query = REPLACE(
|
||||
REPLACE(
|
||||
@tplTruncate
|
||||
,'@schema@'
|
||||
,@schema_name
|
||||
)
|
||||
,'@tbl@'
|
||||
,@tbl_name
|
||||
);
|
||||
|
||||
PRINT @query;
|
||||
EXEC(@query);
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
END
|
||||
|
||||
CLOSE csr_tbl
|
||||
DEALLOCATE csr_tbl
|
||||
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('delphix.arizona_cleanup') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE delphix.arizona_cleanup;
|
||||
END
|
||||
GO
|
||||
|
||||
/*
|
||||
OC-945
|
||||
|
||||
This procedure is used by Delphix to delete content of tables named TT% or ZZ% in the arizona database.
|
||||
As the schema is not unified through all the pharmacies, Delphix cannot be used.
|
||||
*/
|
||||
CREATE PROCEDURE delphix.arizona_cleanup
|
||||
AS
|
||||
BEGIN
|
||||
DECLARE @tbl_name VARCHAR(111), @schema_name VARCHAR(11);
|
||||
DECLARE @tplTruncate VARCHAR(MAX), @query VARCHAR(MAX);
|
||||
SET @tplTruncate='
|
||||
BEGIN TRY
|
||||
TRUNCATE TABLE [arizona].[@schema@].[@tbl@];
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
DELETE FROM [arizona].[@schema@].[@tbl@];
|
||||
END CATCH
|
||||
|
||||
';
|
||||
|
||||
DECLARE csr_tbl CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name], s.[name] as [schema_name]
|
||||
FROM [arizona].[sys].[tables] d
|
||||
INNER JOIN [Arizona].[sys].[schemas] s on s.[schema_id] = d.[schema_id]
|
||||
WHERE [d].[name] LIKE 'TT[_]%'
|
||||
OR [d].[name] LIKE 'ZZ[_]%'
|
||||
|
||||
OPEN csr_tbl
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @query = REPLACE(
|
||||
REPLACE(
|
||||
@tplTruncate
|
||||
,'@schema@'
|
||||
,@schema_name
|
||||
)
|
||||
,'@tbl@'
|
||||
,@tbl_name
|
||||
);
|
||||
|
||||
PRINT @query;
|
||||
EXEC(@query);
|
||||
|
||||
FETCH NEXT FROM csr_tbl INTO @tbl_name, @schema_name
|
||||
END
|
||||
|
||||
CLOSE csr_tbl
|
||||
DEALLOCATE csr_tbl
|
||||
|
||||
END
|
||||
GO
|
||||
begin transaction
|
||||
exec hcitools.delphix.arizonaCust_cleanup;
|
||||
exec hcitools.delphix.hciTool_cleanup;
|
||||
exec hcitools.delphix.arizonaLD_cleanup;
|
||||
exec hcitools.delphix.arizona_cleanup;
|
||||
rollback transaction
|
||||
185
DELPHIX - create target dbs.sql
Normal file
185
DELPHIX - create target dbs.sql
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
Server: samnb705db01.amavita.ch
|
||||
Format: GCM
|
||||
Business: TPPHAR
|
||||
type: VALI
|
||||
Version: 24.1.21007.00072
|
||||
|
||||
08.04.2024, TSC
|
||||
*/
|
||||
USE master
|
||||
|
||||
SET XACT_ABORT ON;
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @dbName NVARCHAR(255);
|
||||
DECLARE @query_bkp NVARCHAR(MAX)='';
|
||||
DECLARE @query_rest NVARCHAR(MAX)='';
|
||||
DECLARE @query_perms NVARCHAR(MAX)='';
|
||||
DECLARE @dump NVARCHAR(255);
|
||||
DECLARE @users TABLE (login VARCHAR(255) NOT NULL,
|
||||
name VARCHAR(255) NOT NULL);
|
||||
INSERT INTO @users ([login],
|
||||
[name])
|
||||
VALUES
|
||||
('svc-delphix-masking','sql login'),
|
||||
('CENTRALINFRA\ua253440', 'Oliver'),
|
||||
('CENTRALINFRA\ua253450', 'Franck'),
|
||||
('CENTRALINFRA\ua210510', 'Wyn');
|
||||
|
||||
DECLARE @tplRight NVARCHAR(MAX) = N'
|
||||
USE @dbName@_delphix
|
||||
BEGIN TRY
|
||||
CREATE USER [@login@] FOR LOGIN [@login@];
|
||||
ALTER ROLE [db_owner] ADD MEMBER [@login@]
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
ALTER ROLE [db_owner] ADD MEMBER [@login@]
|
||||
END CATCH
|
||||
';
|
||||
|
||||
Declare @DataDir nvarchar(4000),
|
||||
@LogDir nvarchar(4000),
|
||||
@BakDir nvarchar(4000),
|
||||
@FTDir nvarchar(4000)
|
||||
|
||||
Exec xp_instance_regread N'HKEY_LOCAL_MACHINE',
|
||||
N'Software\Microsoft\MSSQLServer\MSSQLServer',
|
||||
N'DefaultData',
|
||||
@DataDir output,
|
||||
'no_output'
|
||||
|
||||
Exec xp_instance_regread N'HKEY_LOCAL_MACHINE',
|
||||
N'Software\Microsoft\MSSQLServer\MSSQLServer',
|
||||
N'DefaultLog',
|
||||
@LogDir output,
|
||||
'no_output'
|
||||
|
||||
Exec xp_instance_regread N'HKEY_LOCAL_MACHINE',
|
||||
N'Software\Microsoft\MSSQLServer\MSSQLServer',
|
||||
N'BackupDirectory',
|
||||
@BakDir output,
|
||||
'no_output'
|
||||
|
||||
Exec xp_instance_regread N'HKEY_LOCAL_MACHINE',
|
||||
N'Software\Microsoft\MSSQLServer\MSSQLServer',
|
||||
N'FullTextDefaultPath',
|
||||
@FTDir output,
|
||||
'no_output'
|
||||
|
||||
DECLARE csrDb CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name]
|
||||
FROM sys.databases d
|
||||
WHERE LOWER([d].[name]) IN ( 'arizona', 'arizonarep', 'hcitools', 'arizonacust', 'activepos_read', 'activepos_write' );
|
||||
|
||||
OPEN csrDb;
|
||||
|
||||
FETCH NEXT FROM csrDb
|
||||
INTO @dbName;
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @dump = @dbName+'_dump';
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.[backup_devices]
|
||||
WHERE name = @dump
|
||||
)
|
||||
BEGIN
|
||||
RAISERROR ('No dump device named %s exists', 16, 1, @dump);
|
||||
END
|
||||
ELSE
|
||||
IF @@SERVERNAME IN ('SWAMA707VM01\APSSQL','SWSUN004VM01\APSSQL')
|
||||
BEGIN
|
||||
SET @dump = replace('DISK = N''g:\@dbName@.bak''','@dbName@',@dbname);
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
SET @dump = '['+@dbName+'_dump]';
|
||||
END
|
||||
BEGIN
|
||||
SET @query_bkp = @query_bkp + REPLACE(REPLACE('
|
||||
BACKUP DATABASE [@dbname@] TO @dump@ WITH COPY_ONLY, NOFORMAT, NOINIT, NAME = N''@dbname@-Full Database Backup'', COMPRESSION, SKIP, NOREWIND, NOUNLOAD, STATS = 10;
|
||||
'
|
||||
,'@dbname@'
|
||||
,@dbName)
|
||||
|
||||
,'@dump@'
|
||||
,@dump
|
||||
);
|
||||
|
||||
DECLARE @file_row VARCHAR(255);
|
||||
DECLARE @file_log VARCHAR(255);
|
||||
|
||||
SELECT @file_row = name
|
||||
FROM sys.master_files F
|
||||
WHERE DB_NAME([F].[database_id]) = @dbName
|
||||
AND type_desc = 'ROWS'
|
||||
|
||||
SELECT @file_log = name
|
||||
FROM sys.master_files F
|
||||
WHERE DB_NAME([F].[database_id]) = @dbName
|
||||
AND type_desc = 'LOG'
|
||||
|
||||
IF @@SERVERNAME IN ('SWTSTDB01\APSSQL')
|
||||
BEGIN
|
||||
SET @dataDir = 'e:\SQLDatabase\';
|
||||
END
|
||||
|
||||
SET @query_rest = @query_rest +REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE('
|
||||
RESTORE DATABASE [@dbname@_delphix] FROM @dump@ WITH FILE = 1, REPLACE, MOVE N''@file_row@'' TO N''@dataDir@\@dbname@_delphix.mdf'', MOVE N''@file_Log@'' TO N''@logDir@\@dbname@_delphix_1.ldf'', NOUNLOAD, STATS = 5;
|
||||
ALTER DATABASE [@dbname@_delphix] SET RECOVERY SIMPLE WITH ROLLBACK IMMEDIATE;
|
||||
'
|
||||
,'@dbname@'
|
||||
,@dbName)
|
||||
|
||||
,'@dump@'
|
||||
,@dump)
|
||||
|
||||
,'@file_Log@'
|
||||
,@file_log)
|
||||
|
||||
,'@file_row@'
|
||||
,@file_row
|
||||
)
|
||||
|
||||
,'@dataDir@'
|
||||
,@dataDir
|
||||
)
|
||||
|
||||
,'@logDir@'
|
||||
,@logDir
|
||||
)
|
||||
;
|
||||
|
||||
--permissions
|
||||
SELECT @query_perms = @query_perms + REPLACE(REPLACE(
|
||||
@tplRight
|
||||
,'@dbName@'
|
||||
,@dbName
|
||||
)
|
||||
,'@login@'
|
||||
,u.[login]
|
||||
)
|
||||
FROM @users u
|
||||
|
||||
FETCH NEXT FROM csrDb
|
||||
INTO @dbName;
|
||||
END
|
||||
END
|
||||
|
||||
CLOSE csrDb;
|
||||
DEALLOCATE csrDb;
|
||||
|
||||
|
||||
PRINT @query_bkp;
|
||||
--PRINT '--------------------------------'
|
||||
--PRINT @query_rest
|
||||
--PRINT '--------------------------------'
|
||||
--PRINT @query_perms
|
||||
|
||||
--EXEC(@query_bkp)
|
||||
--EXEC(@query_rest)
|
||||
--EXEC(@query_perms)
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
use Arizona
|
||||
|
||||
|
||||
SELECT obj.name AS FK_NAME,
|
||||
sch.name AS [schema_name],
|
||||
tab1.name AS [table],
|
||||
--col1.name AS [column],
|
||||
sch2.name as [ref_schema],
|
||||
tab2.name AS [referenced_table]
|
||||
--col2.name AS [referenced_column]
|
||||
FROM sys.foreign_key_columns fkc
|
||||
INNER JOIN sys.objects obj
|
||||
ON obj.object_id = fkc.constraint_object_id
|
||||
INNER JOIN sys.tables tab1
|
||||
ON tab1.object_id = fkc.parent_object_id
|
||||
INNER JOIN sys.schemas sch
|
||||
ON tab1.schema_id = sch.schema_id
|
||||
INNER JOIN sys.columns col1
|
||||
ON col1.column_id = parent_column_id AND col1.object_id = tab1.object_id
|
||||
INNER JOIN sys.tables tab2
|
||||
ON tab2.object_id = fkc.referenced_object_id
|
||||
INNER JOIN sys.columns col2
|
||||
ON col2.column_id = referenced_column_id AND col2.object_id = tab2.object_id
|
||||
INNER JOIN sys.schemas sch2
|
||||
ON tab2.schema_id = sch2.schema_id
|
||||
where sch.name <> sch2.name
|
||||
and sch2.name='dbo'
|
||||
11
DELPHIX - get tables with change tracking.sql
Normal file
11
DELPHIX - get tables with change tracking.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
declare @tblList table(tblname varchar(222) null)
|
||||
|
||||
insert into @tblList
|
||||
SELECT DBACTT_table_name
|
||||
FROM dbo.DBA_change_tracking_template
|
||||
;
|
||||
|
||||
select t.TABLE_SCHEMA, t.TABLE_NAME
|
||||
from INFORMATION_SCHEMA.TABLES t
|
||||
join @tblList s on s.tblname = t.TABLE_NAME
|
||||
order by TABLE_SCHEMA, TABLE_NAME
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Server: samnb705db01.amavita.ch
|
||||
Format: GCM
|
||||
Business: TPPHAR
|
||||
type: VALI
|
||||
Version: 23.1.21006.00066
|
||||
|
||||
28.02.2024, TSC
|
||||
*/
|
||||
USE master;
|
||||
|
||||
DECLARE @q NVARCHAR(MAX) = N'';
|
||||
DECLARE @tplLogin NVARCHAR(MAX)
|
||||
= N'
|
||||
IF EXISTS (SELECT 1 FROM master.dbo.syslogins WHERE name = ''@login@'')
|
||||
BEGIN
|
||||
ALTER LOGIN [@login@]
|
||||
WITH DEFAULT_DATABASE = [master],
|
||||
DEFAULT_LANGUAGE = [us_english]
|
||||
--CHECK_EXPIRATION = OFF,
|
||||
--CHECK_POLICY = ON;
|
||||
ALTER LOGIN [@login@] ENABLE;
|
||||
END;
|
||||
ELSE
|
||||
BEGIN
|
||||
CREATE LOGIN [@login@] FROM WINDOWS
|
||||
WITH DEFAULT_DATABASE = [master],
|
||||
DEFAULT_LANGUAGE = [us_english]
|
||||
--CHECK_EXPIRATION = OFF,
|
||||
--CHECK_POLICY = ON;
|
||||
END;
|
||||
';
|
||||
DECLARE @tplRight NVARCHAR(MAX) = N'
|
||||
USE @dbName@
|
||||
IF NOT EXISTS(
|
||||
SELECT *
|
||||
FROM sys.database_principals AS dp
|
||||
INNER JOIN sys.server_principals AS sp ON dp.sid = sp.sid
|
||||
WHERE sp.type_desc IN (''WINDOWS_LOGIN'', ''SQL_LOGIN'')
|
||||
AND sp.name = ''@login@''
|
||||
)
|
||||
BEGIN
|
||||
CREATE USER [@login@] FOR LOGIN [@login@]
|
||||
END
|
||||
|
||||
ALTER ROLE [db_owner] ADD MEMBER [@login@]
|
||||
';
|
||||
|
||||
DECLARE @users TABLE (login VARCHAR(255) NOT NULL,
|
||||
name VARCHAR(255) NOT NULL);
|
||||
INSERT INTO @users ([login],
|
||||
[name])
|
||||
VALUES ('CENTRALINFRA\ua253440', 'Oliver'),
|
||||
('CENTRALINFRA\ua253450', 'Franck'),
|
||||
('CENTRALINFRA\ua193890','Muhamed'),
|
||||
('CENTRALINFRA\ua210510', 'Wyn');
|
||||
|
||||
--#region create logins
|
||||
SELECT @q = @q + REPLACE(@tplLogin, '@login@', [u].[login])
|
||||
FROM @users u;
|
||||
--#endregion create logins
|
||||
|
||||
--#region give rights to db's
|
||||
/* declare variables */
|
||||
DECLARE @dbName NVARCHAR(255),
|
||||
@login VARCHAR(255);
|
||||
|
||||
DECLARE csrDb CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name],
|
||||
[u].[login]
|
||||
FROM sys.databases d
|
||||
CROSS JOIN @users u
|
||||
WHERE LOWER([d].[name]) IN ( 'arizona', 'arizonarep', 'hcitools', 'arizonacust', 'activepos_read', 'activepos_write' );
|
||||
|
||||
OPEN csrDb;
|
||||
|
||||
FETCH NEXT FROM csrDb
|
||||
INTO @dbName,
|
||||
@login;
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @q = @q + REPLACE(REPLACE(@tplRight, '@dbName@', @dbName), '@login@', @login);
|
||||
|
||||
FETCH NEXT FROM csrDb
|
||||
INTO @dbName,
|
||||
@login;
|
||||
END;
|
||||
|
||||
CLOSE csrDb;
|
||||
DEALLOCATE csrDb;
|
||||
--#endregion give rights to db's
|
||||
|
||||
--PRINT @q;
|
||||
|
||||
EXEC (@q);
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Server: samnb705db01.amavita.ch
|
||||
Format: GCM
|
||||
Business: TPPHAR
|
||||
type: VALI
|
||||
Version: 23.1.21006.00066
|
||||
|
||||
28.02.2024, TSC
|
||||
*/
|
||||
USE master;
|
||||
|
||||
DECLARE @q NVARCHAR(MAX) = N'';
|
||||
DECLARE @tplLogin NVARCHAR(MAX) = N'
|
||||
IF EXISTS (SELECT 1 FROM master.dbo.syslogins WHERE name = ''@login@'')
|
||||
BEGIN
|
||||
DROP LOGIN [@login@];
|
||||
PRINT ''Dropped login [@login@]'';
|
||||
END
|
||||
';
|
||||
DECLARE @tplRight NVARCHAR(MAX) = N'
|
||||
USE @dbName@
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM sys.database_principals AS dp
|
||||
INNER JOIN sys.server_principals AS sp ON dp.sid = sp.sid
|
||||
WHERE sp.type_desc IN (''WINDOWS_LOGIN'', ''SQL_LOGIN'')
|
||||
AND sp.name = ''@login@''
|
||||
)
|
||||
BEGIN
|
||||
ALTER ROLE [db_owner] DROP MEMBER [@login@]
|
||||
DROP USER [@login@]
|
||||
PRINT ''Dropped user [@login@] in @dbName@'';
|
||||
END
|
||||
|
||||
';
|
||||
|
||||
DECLARE @users TABLE (login VARCHAR(255) NOT NULL,
|
||||
name VARCHAR(255) NOT NULL);
|
||||
INSERT INTO @users ([login],
|
||||
[name])
|
||||
VALUES ('CENTRALINFRA\ua253440', 'Oliver'),
|
||||
('CENTRALINFRA\ua253450', 'Franck'),
|
||||
('CENTRALINFRA\ua193890','Muhamed'),
|
||||
('CENTRALINFRA\ua210510', 'Wyn');
|
||||
|
||||
|
||||
--#region remove rights to db's
|
||||
/* declare variables */
|
||||
DECLARE @dbName NVARCHAR(255),
|
||||
@login VARCHAR(255);
|
||||
|
||||
DECLARE csrDb CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name],
|
||||
[u].[login]
|
||||
FROM sys.databases d
|
||||
CROSS JOIN @users u
|
||||
WHERE LOWER([d].[name]) IN ( 'arizona', 'arizonarep', 'hcitools', 'arizonacust', 'activepos_read', 'activepos_write' );
|
||||
|
||||
OPEN csrDb;
|
||||
|
||||
FETCH NEXT FROM csrDb
|
||||
INTO @dbName,
|
||||
@login;
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @q = @q + REPLACE(REPLACE(@tplRight, '@dbName@', @dbName), '@login@', @login);
|
||||
|
||||
FETCH NEXT FROM csrDb
|
||||
INTO @dbName,
|
||||
@login;
|
||||
END;
|
||||
|
||||
CLOSE csrDb;
|
||||
DEALLOCATE csrDb;
|
||||
--#endregion remove rights to db's
|
||||
|
||||
--#region process logins
|
||||
SELECT @q = @q + REPLACE(@tplLogin, '@login@', [u].[login])
|
||||
FROM @users u;
|
||||
--#endregion process logins
|
||||
|
||||
--PRINT @q;
|
||||
|
||||
begin tran;
|
||||
EXEC (@q);
|
||||
rollback tran;
|
||||
346
DELPHIX - schema changes.sql
Normal file
346
DELPHIX - schema changes.sql
Normal file
@@ -0,0 +1,346 @@
|
||||
USE [HCITools];
|
||||
|
||||
IF NOT EXISTS(SELECT 1 FROM sys.[schemas] s WHERE s.[name]='delphix')
|
||||
BEGIN
|
||||
EXEC('CREATE SCHEMA [delphix]');
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('delphix.delphix_schema_changes') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE delphix.delphix_schema_changes;
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('dbo.delphix_schema_changes') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE dbo.delphix_schema_changes;
|
||||
END
|
||||
|
||||
|
||||
GO
|
||||
/*
|
||||
OC-945
|
||||
|
||||
This procedure is used by Delphix to alter the schema in the databases that must be masked.
|
||||
It will add new columns to existing tables, that will be used by the masking engine.
|
||||
|
||||
The following fields are added:
|
||||
int arizona.dbo.addresse
|
||||
TT_
|
||||
*/
|
||||
CREATE PROCEDURE delphix.delphix_schema_changes
|
||||
@removeSchemaChanges BIT = 0
|
||||
AS
|
||||
BEGIN
|
||||
SET XACT_ABORT ON;
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @tblAlter TABLE(dbName VARCHAR(50) NOT NULL, queryAlterTxt NVARCHAR(MAX) NOT NULL, queryUpdateTxt NVARCHAR(MAX) NOT NULL);
|
||||
|
||||
IF @removeSchemaChanges = 1
|
||||
BEGIN
|
||||
INSERT INTO @tblAlter ([dbName]
|
||||
,[queryAlterTxt]
|
||||
,[queryUpdateTxt])
|
||||
VALUES(
|
||||
'arizona'
|
||||
,'
|
||||
IF EXISTS(
|
||||
SELECT 1
|
||||
FROM [INFORMATION_SCHEMA].[COLUMNS] c
|
||||
WHERE c.[TABLE_NAME]=''address''
|
||||
AND c.[TABLE_SCHEMA]=''dbo''
|
||||
AND c.[COLUMN_NAME]=''TT_masking''
|
||||
)
|
||||
BEGIN
|
||||
IF (OBJECT_ID(''DF_TT_masking'') IS NOT NULL)
|
||||
BEGIN
|
||||
ALTER TABLE dbo.[Address] DROP CONSTRAINT [DF_TT_masking];
|
||||
END
|
||||
ALTER TABLE dbo.[Address] DROP COLUMN [TT_masking];
|
||||
END
|
||||
'
|
||||
,''
|
||||
)
|
||||
,(
|
||||
'arizona_delphix'
|
||||
,'
|
||||
IF EXISTS(
|
||||
SELECT 1
|
||||
FROM [INFORMATION_SCHEMA].[COLUMNS] c
|
||||
WHERE c.[TABLE_NAME]=''address''
|
||||
AND c.[TABLE_SCHEMA]=''dbo''
|
||||
AND c.[COLUMN_NAME]=''TT_masking''
|
||||
)
|
||||
BEGIN
|
||||
IF (OBJECT_ID(''DF_TT_masking'') IS NOT NULL)
|
||||
BEGIN
|
||||
ALTER TABLE dbo.[Address] DROP CONSTRAINT [DF_TT_masking];
|
||||
END
|
||||
|
||||
ALTER TABLE dbo.[Address] DROP COLUMN [TT_masking];
|
||||
END
|
||||
'
|
||||
,''
|
||||
);
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
INSERT INTO @tblAlter ([dbName]
|
||||
,[queryAlterTxt]
|
||||
,[queryUpdateTxt])
|
||||
VALUES(
|
||||
'arizona'
|
||||
,'
|
||||
IF NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM [INFORMATION_SCHEMA].[COLUMNS] c
|
||||
WHERE c.[TABLE_NAME]=''address''
|
||||
AND c.[TABLE_SCHEMA]=''dbo''
|
||||
AND c.[COLUMN_NAME]=''TT_masking''
|
||||
)
|
||||
BEGIN
|
||||
ALTER TABLE dbo.[Address] ADD TT_masking VARCHAR(50) NOT NULL CONSTRAINT DF_TT_masking DEFAULT ''MASK'';
|
||||
END
|
||||
'
|
||||
,'
|
||||
--set everything to be masked
|
||||
UPDATE ad
|
||||
SET ad.TT_masking = ''MASK''
|
||||
FROM Arizona.dbo.Address ad
|
||||
WHERE ad.TT_masking <> ''MASK'';
|
||||
|
||||
--exclude from masking what we want to keep
|
||||
UPDATE ad
|
||||
SET ad.TT_masking = ''PERSIST''
|
||||
FROM Arizona.dbo.Address ad
|
||||
JOIN Arizona.dbo.Customer cst
|
||||
ON [cst].[CUST_address] = [ad].[Address_ID]
|
||||
LEFT JOIN Arizona.dbo.[Subsidiary] sub
|
||||
ON [cst].[CUST_subsidiary] = [sub].[Subsidiary_ID]
|
||||
WHERE [sub].[Subsidiary_ID] IS NOT NULL
|
||||
AND ( [ad].[AD_last_name] LIKE ''TEST %''
|
||||
OR [ad].[AD_name] LIKE ''TEST %''
|
||||
OR [ad].[AD_last_name] LIKE ''Assura%''
|
||||
OR [ad].[AD_last_name] LIKE ''PRESCRIPTION%''
|
||||
OR [ad].[AD_last_name] LIKE ''RETETE%''
|
||||
OR [ad].[AD_last_name] LIKE ''USER%''
|
||||
OR [ad].[AD_last_name] LIKE ''ONBOARD%''
|
||||
OR [ad].[AD_last_name] LIKE ''SUSPICIOUS%''
|
||||
OR [ad].[AD_last_name] LIKE ''DOE''
|
||||
OR [ad].[AD_last_name] LIKE ''GIALLO%''
|
||||
OR [ad].[AD_last_name] LIKE ''TOLKIEN%''
|
||||
OR [ad].[AD_last_name] LIKE ''DEMO %''
|
||||
OR [ad].[AD_last_name] LIKE ''DOCUMEDIS%''
|
||||
OR [ad].[AD_last_name] = ''DEMO''
|
||||
OR [ad].[AD_last_name] LIKE ''OMNICHANNEL%''
|
||||
OR [ad].[AD_last_name] LIKE ''LASTNAME%''
|
||||
OR [ad].[AD_last_name] LIKE ''MeiXin%''
|
||||
OR [ad].[AD_last_name] LIKE ''DIPLOMATE%''
|
||||
OR [ad].[AD_last_name] LIKE ''NO %''
|
||||
OR [ad].[AD_last_name] LIKE ''ONLY%''
|
||||
OR [ad].[AD_last_name] LIKE ''RDL%''
|
||||
OR [ad].[AD_last_name] LIKE ''USER%''
|
||||
OR [ad].[AD_last_name] LIKE ''GALEXIS%''
|
||||
OR [ad].[AD_last_name] LIKE ''APOS%''
|
||||
OR [ad].[AD_last_name] LIKE ''APOSANDMAGENTO%''
|
||||
OR [ad].[AD_last_name] LIKE ''Activate''
|
||||
OR [ad].[AD_last_name] LIKE ''Sunstore''
|
||||
OR [ad].[AD_last_name] LIKE ''Coopvitality''
|
||||
OR [ad].[AD_last_name] LIKE ''Ama Plus Sun''
|
||||
OR [ad].[AD_last_name] LIKE ''Ama Plus Cvi''
|
||||
OR [ad].[AD_last_name] LIKE ''Sun Plus Cvi''
|
||||
OR [ad].[AD_last_name] LIKE ''Ama Sun Cvi''
|
||||
OR [ad].[AD_last_name] LIKE ''test%[0-9]%''
|
||||
OR [ad].[AD_first_name] LIKE ''test%[0-9]%''
|
||||
OR [ad].[AD_name] LIKE ''%SUNCLUB%''
|
||||
OR [ad].[AD_name] LIKE ''%QUALITY%''
|
||||
OR [ad].[AD_name] LIKE ''%STARCARD%''
|
||||
OR [ad].[AD_name] LIKE ''%CLIENT%''
|
||||
OR [ad].[AD_name] LIKE ''%MAGENTO%''
|
||||
OR [ad].[AD_name] LIKE ''%RENOUVELLEMENT%''
|
||||
OR [ad].[AD_name] LIKE ''%Mitarbeiter%''
|
||||
OR [ad].[AD_name] LIKE ''% DEV %''
|
||||
OR [ad].[AD_name] LIKE ''CERN Service%''
|
||||
OR [ad].[AD_name] LIKE ''BALEXERT CENTRE%''
|
||||
OR [ad].[AD_name] LIKE ''G.H.O.L.%''
|
||||
OR [ad].[AD_first_name] LIKE ''Test %''
|
||||
OR [ad].[AD_first_name] = ''Test''
|
||||
OR [ad].[AD_first_name] LIKE ''ONLYAPOS%''
|
||||
OR [ad].[AD_first_name] LIKE ''In APOS%''
|
||||
OR [ad].[AD_last_name] = ''DEMO''
|
||||
OR (
|
||||
[ad].[Address_ID] < 1500000000
|
||||
AND NOT EXISTS (SELECT 3 FROM [dbo].[Employee] WHERE EM_address = ad.Address_ID)
|
||||
AND NOT EXISTS (SELECT 3 FROM [dbo].[Customer] WHERE CUST_address = ad.Address_ID)
|
||||
)
|
||||
)
|
||||
AND [ad].[TT_masking] <> ''PERSIST''
|
||||
|
||||
UPDATE ad
|
||||
SET [ad].[TT_masking] = ''PERSIST''
|
||||
FROM Arizona.dbo.PH_prescriber ph
|
||||
INNER JOIN Arizona.dbo.Address ad
|
||||
ON [ad].[Address_ID] = [ph].[PHPR_address]
|
||||
WHERE [ph].[PHPR_deactivation_date] IS NULL
|
||||
AND [ad].[TT_masking] <> ''PERSIST'';
|
||||
'
|
||||
)
|
||||
,(
|
||||
'arizona_delphix'
|
||||
,'
|
||||
IF NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM [INFORMATION_SCHEMA].[COLUMNS] c
|
||||
WHERE c.[TABLE_NAME]=''address''
|
||||
AND c.[TABLE_SCHEMA]=''dbo''
|
||||
AND c.[COLUMN_NAME]=''TT_masking''
|
||||
)
|
||||
BEGIN
|
||||
ALTER TABLE dbo.[Address] ADD TT_masking VARCHAR(50) NOT NULL CONSTRAINT DF_TT_masking DEFAULT ''MASK'';
|
||||
END
|
||||
'
|
||||
,'
|
||||
--set everything to be masked
|
||||
UPDATE ad
|
||||
SET ad.TT_masking = ''MASK''
|
||||
FROM Arizona.dbo.Address ad
|
||||
WHERE ad.TT_masking <> ''MASK'';
|
||||
|
||||
--exclude from masking what we want to keep
|
||||
UPDATE ad
|
||||
SET ad.TT_masking = ''PERSIST''
|
||||
FROM Arizona.dbo.Address ad
|
||||
JOIN Arizona.dbo.Customer cst
|
||||
ON [cst].[CUST_address] = [ad].[Address_ID]
|
||||
LEFT JOIN Arizona.dbo.[Subsidiary] sub
|
||||
ON [cst].[CUST_subsidiary] = [sub].[Subsidiary_ID]
|
||||
WHERE [sub].[Subsidiary_ID] IS NOT NULL
|
||||
AND ( [ad].[AD_last_name] LIKE ''TEST %''
|
||||
OR [ad].[AD_name] LIKE ''TEST %''
|
||||
OR [ad].[AD_last_name] LIKE ''Assura%''
|
||||
OR [ad].[AD_last_name] LIKE ''PRESCRIPTION%''
|
||||
OR [ad].[AD_last_name] LIKE ''RETETE%''
|
||||
OR [ad].[AD_last_name] LIKE ''USER%''
|
||||
OR [ad].[AD_last_name] LIKE ''ONBOARD%''
|
||||
OR [ad].[AD_last_name] LIKE ''SUSPICIOUS%''
|
||||
OR [ad].[AD_last_name] LIKE ''DOE''
|
||||
OR [ad].[AD_last_name] LIKE ''GIALLO%''
|
||||
OR [ad].[AD_last_name] LIKE ''TOLKIEN%''
|
||||
OR [ad].[AD_last_name] LIKE ''DEMO %''
|
||||
OR [ad].[AD_last_name] LIKE ''DOCUMEDIS%''
|
||||
OR [ad].[AD_last_name] = ''DEMO''
|
||||
OR [ad].[AD_last_name] LIKE ''OMNICHANNEL%''
|
||||
OR [ad].[AD_last_name] LIKE ''LASTNAME%''
|
||||
OR [ad].[AD_last_name] LIKE ''MeiXin%''
|
||||
OR [ad].[AD_last_name] LIKE ''DIPLOMATE%''
|
||||
OR [ad].[AD_last_name] LIKE ''NO %''
|
||||
OR [ad].[AD_last_name] LIKE ''ONLY%''
|
||||
OR [ad].[AD_last_name] LIKE ''RDL%''
|
||||
OR [ad].[AD_last_name] LIKE ''USER%''
|
||||
OR [ad].[AD_last_name] LIKE ''GALEXIS%''
|
||||
OR [ad].[AD_last_name] LIKE ''APOS%''
|
||||
OR [ad].[AD_last_name] LIKE ''APOSANDMAGENTO%''
|
||||
OR [ad].[AD_last_name] LIKE ''Activate''
|
||||
OR [ad].[AD_last_name] LIKE ''Sunstore''
|
||||
OR [ad].[AD_last_name] LIKE ''Coopvitality''
|
||||
OR [ad].[AD_last_name] LIKE ''Ama Plus Sun''
|
||||
OR [ad].[AD_last_name] LIKE ''Ama Plus Cvi''
|
||||
OR [ad].[AD_last_name] LIKE ''Sun Plus Cvi''
|
||||
OR [ad].[AD_last_name] LIKE ''Ama Sun Cvi''
|
||||
OR [ad].[AD_last_name] LIKE ''test%[0-9]%''
|
||||
OR [ad].[AD_first_name] LIKE ''test%[0-9]%''
|
||||
OR [ad].[AD_name] LIKE ''%SUNCLUB%''
|
||||
OR [ad].[AD_name] LIKE ''%QUALITY%''
|
||||
OR [ad].[AD_name] LIKE ''%STARCARD%''
|
||||
OR [ad].[AD_name] LIKE ''%CLIENT%''
|
||||
OR [ad].[AD_name] LIKE ''%MAGENTO%''
|
||||
OR [ad].[AD_name] LIKE ''%RENOUVELLEMENT%''
|
||||
OR [ad].[AD_name] LIKE ''%Mitarbeiter%''
|
||||
OR [ad].[AD_name] LIKE ''% DEV %''
|
||||
OR [ad].[AD_name] LIKE ''CERN Service%''
|
||||
OR [ad].[AD_name] LIKE ''BALEXERT CENTRE%''
|
||||
OR [ad].[AD_name] LIKE ''G.H.O.L.%''
|
||||
OR [ad].[AD_first_name] LIKE ''Test %''
|
||||
OR [ad].[AD_first_name] = ''Test''
|
||||
OR [ad].[AD_first_name] LIKE ''ONLYAPOS%''
|
||||
OR [ad].[AD_first_name] LIKE ''In APOS%''
|
||||
OR [ad].[AD_last_name] = ''DEMO''
|
||||
OR (
|
||||
[ad].[Address_ID] < 1500000000
|
||||
AND NOT EXISTS (SELECT 3 FROM [dbo].[Employee] WHERE EM_address = ad.Address_ID)
|
||||
AND NOT EXISTS (SELECT 3 FROM [dbo].[Customer] WHERE CUST_address = ad.Address_ID)
|
||||
)
|
||||
)
|
||||
AND [ad].[TT_masking] <> ''PERSIST''
|
||||
|
||||
UPDATE ad
|
||||
SET [ad].[TT_masking] = ''PERSIST''
|
||||
FROM Arizona.dbo.PH_prescriber ph
|
||||
INNER JOIN Arizona.dbo.Address ad
|
||||
ON [ad].[Address_ID] = [ph].[PHPR_address]
|
||||
WHERE [ph].[PHPR_deactivation_date] IS NULL
|
||||
AND [ad].[TT_masking] <> ''PERSIST'';
|
||||
'
|
||||
);
|
||||
END
|
||||
|
||||
/* declare variables */
|
||||
DECLARE @dbName VARCHAR(50), @queryAlterTxt NVARCHAR(MAX), @queryUpdateTxt NVARCHAR(MAX), @queryComplete NVARCHAR(MAX);
|
||||
|
||||
DECLARE csrAlter CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [dbName],
|
||||
[queryAlterTxt],
|
||||
[queryUpdateTxt]
|
||||
FROM @tblAlter s
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.databases d
|
||||
WHERE d.[name] = s.[dbName]
|
||||
)
|
||||
|
||||
OPEN csrAlter
|
||||
|
||||
FETCH NEXT FROM csrAlter INTO @dbName, @queryAlterTxt, @queryUpdateTxt
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @queryComplete='USE '+@dbName+';'+CHAR(13)+CHAR(10)+@queryAlterTxt;
|
||||
--PRINT @queryComplete;
|
||||
EXEC(@queryComplete);
|
||||
|
||||
SET @queryComplete='USE '+@dbName+';'+CHAR(13)+CHAR(10)+@queryUpdateTxt;
|
||||
--PRINT @queryComplete;
|
||||
EXEC(@queryComplete);
|
||||
|
||||
FETCH NEXT FROM csrAlter INTO @dbName, @queryAlterTxt, @queryUpdateTxt
|
||||
END
|
||||
|
||||
CLOSE csrAlter
|
||||
DEALLOCATE csrAlter
|
||||
END
|
||||
GO
|
||||
|
||||
BEGIN TRANSACTION
|
||||
EXEC delphix.[delphix_schema_changes] @removeSchemaChanges = 0
|
||||
|
||||
EXEC('
|
||||
SELECT ''arizona'' as db_name, COUNT(1) AS cnt, TT_masking
|
||||
FROM arizona.dbo.[Address]
|
||||
GROUP BY TT_masking
|
||||
')
|
||||
|
||||
IF EXISTS(SELECT 1 FROM sys.[databases] WHERE name ='arizona_delphix')
|
||||
EXEC('
|
||||
SELECT ''arizona_delphix'' as db_name, COUNT(1) AS cnt, TT_masking
|
||||
FROM arizona_delphix.dbo.[Address]
|
||||
GROUP BY TT_masking
|
||||
')
|
||||
|
||||
EXEC delphix.[delphix_schema_changes] @removeSchemaChanges = 1
|
||||
SELECT TOP 10 * FROM [Arizona].[dbo].[Address];
|
||||
|
||||
|
||||
ROLLBACK TRANSACTION
|
||||
--COMMIT TRANSACTION
|
||||
1130
DELPHIX - used tables from central index usage.sql
Normal file
1130
DELPHIX - used tables from central index usage.sql
Normal file
File diff suppressed because it is too large
Load Diff
68
DELPHIX DBG - restore arizona_delphix.sql
Normal file
68
DELPHIX DBG - restore arizona_delphix.sql
Normal file
@@ -0,0 +1,68 @@
|
||||
use master
|
||||
|
||||
RESTORE DATABASE [Arizona_delphix] FROM [Arizona_dump_secu] WITH FILE = 1, REPLACE, MOVE N'Arizona_Data' TO N'F:\SQLDataBase\Arizona_delphix.mdf', MOVE N'Arizona_Log' TO N'G:\SQLDataBase\Arizona_delphix_1.ldf', NOUNLOAD, STATS = 5;
|
||||
|
||||
ALTER DATABASE [Arizona_delphix] SET RECOVERY SIMPLE WITH ROLLBACK IMMEDIATE;
|
||||
|
||||
ALTER DATABASE arizona_delphix SET ALLOW_SNAPSHOT_ISOLATION ON
|
||||
ALTER DATABASE arizona_delphix SET READ_COMMITTED_SNAPSHOT ON
|
||||
EXEC hciTools.[delphix].[delphix_schema_changes] @removeSchemaChanges = 0
|
||||
|
||||
|
||||
select 'az' as src, *
|
||||
from arizona.information_schema.columns c
|
||||
where c.table_name ='address'
|
||||
and c.column_name = 'tt_masking'
|
||||
|
||||
if @@rowcount > 0
|
||||
begin
|
||||
print 'drop default constraint and columns tt_masking on arizona'
|
||||
alter table arizona.dbo.address drop constraint df_tt_masking
|
||||
alter table arizona.dbo.address drop column tt_masking
|
||||
end
|
||||
|
||||
use master
|
||||
|
||||
select 'az_delphix' as src, *
|
||||
from arizona_delphix.information_schema.columns c
|
||||
where c.table_name ='address'
|
||||
and c.column_name = 'tt_masking'
|
||||
|
||||
select tt_masking, COUNT(1)
|
||||
from Arizona_delphix.dbo.address a
|
||||
group by tt_masking
|
||||
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
--use arizona_delphix
|
||||
--ALTER TABLE arizona_delphix.AP.WebShopStatusQueue DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.DL_posology DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Document_header DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Document_line DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Document_line_link DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Item_inventory DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Item_quantity DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Item_seasonal_stock_info DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Item_standard_cost DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.LORE_item_ABC_code DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.LORE_supplying_procedure DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.PH_insurance_card DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.PH_insurance_plan DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.PH_insurance_recommendation DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.PH_patient DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.PH_prescription_header DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.PH_prescription_line DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.dbo.Price_modifier DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.DocumentSignature DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.GoodsReceipt DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.GoodsReceiptLine DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.MissedSale DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.OrderRequest DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.OrderRequestLine DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.PurchaseReturn DISABLE CHANGE_TRACKING;
|
||||
--ALTER TABLE arizona_delphix.wkl.PurchaseReturnLine DISABLE CHANGE_TRACKING;
|
||||
|
||||
--alter table arizona_delphix.[wkl].[DeliveryNote] drop constraint [FK_DeliveryNote_Supplier];
|
||||
44
EXPLOIT - change compatibility mode for all db's.sql
Normal file
44
EXPLOIT - change compatibility mode for all db's.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
DECLARE @tpl NVARCHAR(MAX)
|
||||
= N'
|
||||
SET DEADLOCK_PRIORITY LOW /* to avoid killing client transaction */
|
||||
ALTER DATABASE [@db@]
|
||||
SET COMPATIBILITY_LEVEL = 160;
|
||||
';
|
||||
|
||||
--begin transaction;
|
||||
--set xact_abort on;
|
||||
|
||||
/* declare variables */
|
||||
DECLARE @db VARCHAR(100);
|
||||
DECLARE @query NVARCHAR(MAX) = N'';
|
||||
|
||||
DECLARE csr_dbs CURSOR FAST_FORWARD READ_ONLY FOR
|
||||
SELECT [d].[name]
|
||||
FROM [sys].[databases] d
|
||||
WHERE [d].[is_read_only] = 0
|
||||
AND [d].[state_desc] = 'online'
|
||||
AND [d].[source_database_id] IS NULL
|
||||
AND [d].[compatibility_level] <> 160;
|
||||
|
||||
OPEN csr_dbs;
|
||||
|
||||
FETCH NEXT FROM csr_dbs
|
||||
INTO @db;
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
SET @query = REPLACE(@tpl, '@db@', @db);
|
||||
PRINT @query;
|
||||
raiserror('Applying setting on %s',0,0,@db) with nowait;
|
||||
exec(@query);
|
||||
raiserror('done',0,0,@db) with nowait;
|
||||
raiserror('-----',0,0,@db) with nowait;
|
||||
|
||||
FETCH NEXT FROM csr_dbs
|
||||
INTO @db;
|
||||
END
|
||||
|
||||
CLOSE csr_dbs;
|
||||
DEALLOCATE csr_dbs;
|
||||
|
||||
--rollback transaction;
|
||||
23
EXPLOIT - check last full backup date.sql
Normal file
23
EXPLOIT - check last full backup date.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
USE master; -- Ensure you are connected to the master database
|
||||
GO
|
||||
|
||||
-- Retrieve the last full backup date for the specified database
|
||||
SELECT top 10
|
||||
b.backup_start_date AS BackupDate,
|
||||
CASE
|
||||
WHEN b.type = 'D' THEN 'Full'
|
||||
WHEN b.type = 'L' THEN 'Log'
|
||||
ELSE 'Other'
|
||||
END AS BackupType
|
||||
FROM msdb.dbo.backupset b
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
database_name,
|
||||
MAX(backup_start_date) AS last_backup_date
|
||||
FROM msdb.dbo.backupset
|
||||
WHERE database_name = 'arizona'
|
||||
GROUP BY database_name
|
||||
) maxb ON b.database_name = maxb.database_name
|
||||
--AND b.backup_start_date = maxb.last_backup_date
|
||||
and b.type = 'D'
|
||||
order by backup_finish_date desc
|
||||
134
EXPLOIT - disk usage and db size.sql
Normal file
134
EXPLOIT - disk usage and db size.sql
Normal file
@@ -0,0 +1,134 @@
|
||||
--databases space
|
||||
IF OBJECT_ID('tempdb..#dbs')IS NOT NULL BEGIN;
|
||||
DROP TABLE #dbs;
|
||||
END;
|
||||
|
||||
CREATE TABLE #dbs ( [database_name] NVARCHAR(128), [log_size_mb] DECIMAL(18,2), [row_size_mb] DECIMAL(18,2), [total_size_mb] DECIMAL(18,2) )
|
||||
|
||||
INSERT INTO [#dbs] ([database_name], [log_size_mb], [row_size_mb], [total_size_mb])
|
||||
SELECT
|
||||
database_name = DB_NAME(database_id)
|
||||
, log_size_mb = CAST(SUM(CASE WHEN f.type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(18,2))
|
||||
, row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(18,2))
|
||||
, total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(18,2))
|
||||
FROM sys.master_files F WITH(NOWAIT)
|
||||
GROUP BY F.database_id
|
||||
ORDER BY [total_size_mb] DESC
|
||||
|
||||
IF OBJECT_ID('tempdb..#FileSize')IS NOT NULL BEGIN;
|
||||
DROP TABLE #FileSize;
|
||||
END;
|
||||
CREATE TABLE #FileSize(
|
||||
dbName NVARCHAR(128) NOT NULL,
|
||||
FileName NVARCHAR(128) NOT NULL,
|
||||
type_desc NVARCHAR(128) NOT NULL,
|
||||
CurrentSizeMB DECIMAL(10,2) NOT NULL,
|
||||
FreeSpaceMB DECIMAL(10,2) NULL
|
||||
)
|
||||
INSERT INTO #FileSize(dbName, FileName, type_desc, CurrentSizeMB, FreeSpaceMB)
|
||||
exec sp_msforeachdb
|
||||
'use [?];
|
||||
SELECT DB_NAME() AS DbName,
|
||||
name AS FileName,
|
||||
type_desc,
|
||||
size/128.0 AS CurrentSizeMB,
|
||||
size/128.0 - CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT)/128.0 AS FreeSpaceMB
|
||||
FROM sys.database_files
|
||||
WHERE type IN (0,1);';
|
||||
|
||||
/*
|
||||
SELECT *
|
||||
FROM #FileSize
|
||||
*/
|
||||
|
||||
SELECT
|
||||
d.[name] AS dbName
|
||||
,f.[physical_name] AS physicalFileName
|
||||
,f.[name] AS logicalFileName
|
||||
--,d2.[log_size_mb]
|
||||
--,d2.[row_size_mb]
|
||||
,'-----' AS separator
|
||||
,CAST(f.size * 8.0 / 1024 AS DECIMAL(18,2)) AS fileSizeMB
|
||||
,fs.[FreeSpaceMB] AS FreeSpaceInFileMB
|
||||
,fs.[CurrentSizeMB] - fs.[FreeSpaceMB] AS SpaceUsedMB
|
||||
,CAST((fs.[CurrentSizeMB] - fs.[FreeSpaceMB]) * 100 / (CAST(f.size * 8. / 1024 AS DECIMAL(18,2))) AS NUMERIC(6,2)) AS fileSpaceUsedPercent
|
||||
,'-----' AS separator
|
||||
,d2.[total_size_mb] AS totalDbSizeMB
|
||||
,'USE '+d.name+';
|
||||
DBCC SHRINKFILE (N'''+f.[name]+''' , 0, TRUNCATEONLY);
|
||||
GO
|
||||
|
||||
' AS shrinkData
|
||||
,'USE '+d.name+';
|
||||
DBCC SHRINKFILE (N'''+f.[name]+''' , 1024);
|
||||
GO
|
||||
|
||||
' AS reorganizeData
|
||||
,'USE '+d.name+';
|
||||
IF 1024 < '+CAST(CAST(f.size * 8.0 / 1024 AS DECIMAL(18,2)) AS VARCHAR(15))+' --file is above 1Go
|
||||
AND 95 > '+CAST(CAST((fs.[CurrentSizeMB] - fs.[FreeSpaceMB]) * 100 / (CAST(f.size * 8.0 / 1024 AS DECIMAL(18,2))) AS DECIMAL(6,2))AS VARCHAR(15))+' --and usage below 95%
|
||||
AND 0 < '+CAST(CAST(fs.[CurrentSizeMB] - fs.[FreeSpaceMB] AS DECIMAL(16,2))AS VARCHAR(15))+' --and data are present
|
||||
BEGIN
|
||||
--print ''Reorganize '+d.name+'.'+f.name+' ''
|
||||
RAISERROR(''Reorganize '+d.name+'.'+f.name+' '',0,0) WITH NOWAIT
|
||||
|
||||
DBCC SHRINKFILE (N'''+f.[name]+''' , '+CAST(CAST(fs.[CurrentSizeMB] - fs.[FreeSpaceMB] + 1024 AS DECIMAL(18,0)) AS VARCHAR(15))+');
|
||||
RAISERROR(''Done'',0,0) WITH NOWAIT
|
||||
END
|
||||
GO
|
||||
' AS auto_action
|
||||
FROM sys.master_files F
|
||||
JOIN sys.databases d ON d.[database_id] = f.[database_id]
|
||||
JOIN [#dbs] [d2] ON d2.[database_name] = d.[name]
|
||||
LEFT JOIN [#FileSize] fs ON fs.[FileName] = f.name AND fs.[dbName] = d.[name]
|
||||
WHERE f.type_desc IN (
|
||||
'ROWS' --mdf
|
||||
--,'LOG'
|
||||
)
|
||||
--AND f.[physical_name] LIKE 'f%'
|
||||
--AND d.[is_read_only] = 0
|
||||
--AND d.[is_auto_shrink_on] = 0
|
||||
--AND d.name='sl2007'
|
||||
AND d.name NOT IN (
|
||||
'master'
|
||||
,'tempdb'
|
||||
,'model'
|
||||
,'msdb'
|
||||
)
|
||||
ORDER BY [d2].[row_size_mb] DESC, d.name DESC, f.name ASC ;
|
||||
|
||||
--free disk space
|
||||
SELECT
|
||||
CONVERT(VARCHAR(512), [b].[volume_mount_point]) AS [volume_mount_point],
|
||||
CONVERT(VARCHAR(512), [b].[logical_volume_name]) AS [logical_volume_name],
|
||||
CONVERT(DECIMAL(18, 1), ROUND(((SUM(CONVERT(FLOAT, [b].[available_bytes])) / SUM(CONVERT(FLOAT, [b].[total_bytes]))) * 100), 1)) AS [percent_free],
|
||||
CONVERT(BIGINT, ROUND(((SUM([b].[available_bytes]) / 1024.0) / 1024.0 / 1024.0), 0)) AS [free_gb],
|
||||
CONVERT(BIGINT, ROUND(((SUM([b].[available_bytes]) / 1024.0) / 1024.0), 0)) AS [free_mb],
|
||||
CONVERT(BIGINT, ROUND(((SUM([b].[total_bytes]) / 1024.0) / 1024.0 / 1024.0), 0)) AS [total_gb],
|
||||
CONVERT(BIGINT, ROUND((((SUM([b].[total_bytes] - [b].[available_bytes])) / 1024.0) / 1024.0 / 1024.0), 0)) AS [used_gb],
|
||||
CONVERT(BIGINT, ROUND(((SUM([b].[total_bytes]) / 1024.0) / 1024.0), 0)) / 100 * 5 / 1024.0 AS [5% space in Go is],
|
||||
CONVERT(BIGINT, ROUND(((SUM([b].[total_bytes]) / 1024.0) / 1024.0), 0)) / 100 * 10 / 1024.0 AS [10% space in Go is],
|
||||
CONVERT(BIGINT, ROUND(((SUM([b].[total_bytes]) / 1024.0) / 1024.0), 0)) / 100 * 15 / 1024.0 AS [15% space in Go is],
|
||||
CURRENT_TIMESTAMP AS now,
|
||||
REPLACE(@@SERVERNAME, '\apssql', '') AS srvName
|
||||
FROM sys.master_files AS [a]
|
||||
CROSS APPLY (
|
||||
SELECT [x].[database_id],
|
||||
[x].[file_id],
|
||||
[x].[volume_mount_point],
|
||||
[x].[volume_id],
|
||||
[x].[logical_volume_name],
|
||||
[x].[file_system_type],
|
||||
[x].[total_bytes],
|
||||
[x].[available_bytes],
|
||||
[x].[supports_compression],
|
||||
[x].[supports_alternate_streams],
|
||||
[x].[supports_sparse_files],
|
||||
[x].[is_read_only],
|
||||
[x].[is_compressed],
|
||||
ROW_NUMBER() OVER (PARTITION BY [x].[volume_mount_point]
|
||||
ORDER BY [x].[volume_mount_point] DESC) AS rnk
|
||||
FROM sys.dm_os_volume_stats(a.database_id, a.[file_id]) x ) b
|
||||
WHERE [b].[rnk] = 1
|
||||
GROUP BY [b].[logical_volume_name], [b].[volume_mount_point]
|
||||
ORDER BY [b].[volume_mount_point] ASC;
|
||||
4
EXPLOIT - identity.sql
Normal file
4
EXPLOIT - identity.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
SELECT *
|
||||
FROM [master].cfg.[Identity] [i]
|
||||
SELECT *
|
||||
FROM master.cfg.[InstanceContext] [ic]
|
||||
29
EXPLOIT - last db full backup.sql
Normal file
29
EXPLOIT - last db full backup.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
;WITH cteHist AS (
|
||||
SELECT [ibs].[database_name], [ibs].[backup_start_date], [ibs].[backup_finish_date], ROW_NUMBER()OVER(PARTITION BY [ibs].[database_name] ORDER BY [ibs].[backup_finish_date] DESC ) AS rnk
|
||||
FROM msdb.dbo.backupset ibs
|
||||
WHERE [ibs].[type]='D'
|
||||
)
|
||||
, ctehistFilt AS (
|
||||
SELECT *
|
||||
FROM [cteHist]
|
||||
--WHERE [cteHist].[rnk] <= 10
|
||||
WHERE [cteHist].[backup_finish_date] >= DATEADD(DAY, -7, CURRENT_TIMESTAMP)
|
||||
)
|
||||
|
||||
SELECT
|
||||
d.name
|
||||
--,[last 5 backups] = STUFF(CONVERT(VARCHAR(MAX),bkp.strDates),1,1,'')
|
||||
,h.[backup_finish_date]
|
||||
,h.[rnk] AS position
|
||||
,d.collation_name
|
||||
,d.compatibility_level
|
||||
FROM sys.databases d
|
||||
JOIN [ctehistFilt] h ON h.[database_name] = d.[name]
|
||||
WHERE 1=1
|
||||
and rnk = 1
|
||||
AND d.name NOT IN (
|
||||
'master'
|
||||
,'model'
|
||||
,'tempdb'
|
||||
,'msdb'
|
||||
)
|
||||
35
EXPLOIT - missing db backup path 2 setting.sql
Normal file
35
EXPLOIT - missing db backup path 2 setting.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
if exists(
|
||||
SELECT *
|
||||
FROM ActiveSystemServer.cfg.Settings
|
||||
WHERE SettingId LIKE 'Values.Modules.Replication.DbInitializationBackupPath%'
|
||||
--AND LEN(SettingValue) > 1;
|
||||
)
|
||||
select 1 as ok
|
||||
else
|
||||
select 0 as ok
|
||||
|
||||
return
|
||||
|
||||
begin tran
|
||||
INSERT INTO ActiveSystemServer.cfg.[Settings] ([ApplicationId],
|
||||
[SettingId],
|
||||
[SettingValue],
|
||||
[SettingTypeName],
|
||||
[SettingIsFavorite],
|
||||
[SettingIsAdmin],
|
||||
[SettingPredefinedValues],
|
||||
[SettingDocumentation])
|
||||
SELECT '57DDA4A4-5004-4458-A749-C01EA953FC4C' AS [ApplicationId],
|
||||
'Values.Modules.Replication.DbInitializationBackupPath2' AS [SettingId],
|
||||
'' AS [SettingValue],
|
||||
'String' AS [SettingTypeName],
|
||||
0 AS [SettingIsFavorite],
|
||||
1 AS [SettingIsAdmin],
|
||||
NULL AS [SettingPredefinedValues],
|
||||
NULL AS [SettingDocumentation]
|
||||
WHERE NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM ActiveSystemServer.cfg.Settings s
|
||||
WHERE s.[SettingId] = 'Values.Modules.Replication.DbInitializationBackupPath2'
|
||||
)
|
||||
rollback tran
|
||||
3
EXPLOIT - restart activePosClientService.sql
Normal file
3
EXPLOIT - restart activePosClientService.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
EXEC xp_cmdshell 'net stop ActiveposClientService';
|
||||
|
||||
EXEC xp_cmdshell 'net start ActiveposClientService'
|
||||
20
EXPLOIT - restart all distribution jobs.sql
Normal file
20
EXPLOIT - restart all distribution jobs.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
DECLARE @tpl VARCHAR(255)='exec msdb.dbo.sp_start_job @job_name= ''@job@''; '+CHAR(13)+CHAR(10)
|
||||
DECLARE @q VARCHAR(MAX)='';
|
||||
|
||||
SELECT @q = @q + REPLACE(@tpl, '@job@', j.name)
|
||||
FROM msdb.dbo.sysjobs j
|
||||
WHERE name LIKE 'ActivePosTran distribution agent -%'
|
||||
AND NOT EXISTS(
|
||||
--the job is currently running
|
||||
SELECT 1
|
||||
FROM msdb.dbo.sysjobactivity sja
|
||||
WHERE sja.job_id = j.job_id
|
||||
AND sja.start_execution_date IS NOT NULL
|
||||
AND sja.stop_execution_date IS NULL
|
||||
)
|
||||
|
||||
IF @q <> ''
|
||||
BEGIN
|
||||
PRINT @q
|
||||
EXEC(@q)
|
||||
END
|
||||
27
EXPLOIT - start a job if not running.sql
Normal file
27
EXPLOIT - start a job if not running.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
DECLARE @job NVARCHAR(MAX)='DR00510 - TriaFin subscription agent';
|
||||
|
||||
IF NOT EXISTS(
|
||||
SELECT [j].[name] AS [job_name],
|
||||
[j].[job_id],
|
||||
[a].[run_requested_date],
|
||||
[a].[next_scheduled_run_date],
|
||||
[a].[start_execution_date],
|
||||
[a].[stop_execution_date]
|
||||
FROM [msdb].[dbo].[sysjobs] [j]
|
||||
JOIN (
|
||||
SELECT MAX([session_id]) AS [session_id],
|
||||
[job_id]
|
||||
FROM [msdb].[dbo].[sysjobactivity] [ia]
|
||||
GROUP BY [job_id]
|
||||
) [sess] ON [sess].[job_id] = [j].[job_id]
|
||||
JOIN [msdb].[dbo].[sysjobactivity] [a] ON [a].[job_id] = [j].[job_id] AND [sess].[session_id] = [a].[session_id]
|
||||
|
||||
WHERE [j].[name] = @job
|
||||
AND [start_execution_date] IS NOT NULL
|
||||
AND [stop_execution_date] IS NULL
|
||||
)
|
||||
AND EXISTS(SELECT 1 FROM msdb.dbo.[sysjobs] WHERE name=@job)
|
||||
BEGIN
|
||||
EXEC [msdb].[dbo].[sp_start_job] @job_name = @job
|
||||
PRINT 'started job '+@job
|
||||
END
|
||||
28
EXPLOIT - start replication agents that are stopped.sql
Normal file
28
EXPLOIT - start replication agents that are stopped.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
DECLARE @tpl VARCHAR(255)='exec [msdb].[dbo].[sp_start_job] @job_name= ''@job@''; '+CHAR(13)+CHAR(10)
|
||||
DECLARE @q VARCHAR(MAX)='';
|
||||
|
||||
WITH cteActivity AS (
|
||||
SELECT job_id, session_id, ROW_NUMBER()OVER(PARTITION BY job_id ORDER BY start_execution_date DESC) AS rnk
|
||||
FROM msdb.dbo.sysjobactivity
|
||||
)
|
||||
|
||||
SELECT @q = @q + REPLACE(@tpl, '@job@', j.name)
|
||||
FROM msdb.dbo.sysjobs j
|
||||
WHERE name LIKE 'ActivePosTran distribution agent -%'
|
||||
AND NOT EXISTS(
|
||||
--the job is currently running
|
||||
SELECT 1
|
||||
FROM msdb.dbo.sysjobactivity sja
|
||||
JOIN cteActivity ca ON ca.job_id = sja.job_id AND ca.session_id = sja.session_id
|
||||
WHERE sja.job_id = j.job_id
|
||||
AND ca.rnk=1
|
||||
AND sja.start_execution_date IS NOT NULL
|
||||
AND sja.stop_execution_date IS NULL
|
||||
)
|
||||
|
||||
IF NULLIF(@q,'') IS NOT NULL
|
||||
BEGIN
|
||||
PRINT @q
|
||||
select @q
|
||||
EXEC(@q)
|
||||
END
|
||||
1
EXPLOIT - start replication.sql
Normal file
1
EXPLOIT - start replication.sql
Normal file
@@ -0,0 +1 @@
|
||||
exec msdb.dbo.sp_start_job @job_name='D00480 - ActivePos_read Snapshot'
|
||||
163
EXPLOIT - syncro h gcmtestcent.sql
Normal file
163
EXPLOIT - syncro h gcmtestcent.sql
Normal file
@@ -0,0 +1,163 @@
|
||||
use arizona
|
||||
|
||||
|
||||
return
|
||||
|
||||
/* 10.03.2020 CEG - Synchronisation horizontale */
|
||||
/* _D01500 - SYNC - H Synchronize items and addresses */
|
||||
/* La correction de la synchronisation Horizontale se fait uniquement sur la central SUN (suncent) dans la base Arizona. */
|
||||
|
||||
/* AMR des données de la table en erreur */
|
||||
select amr.AMR_horizontal_extraction_TS, amr.AMR_aps_ts, amr.AMR_extraction_timestamp, amr.*
|
||||
from aps_monitor_row amr ( nolock)
|
||||
join APS_monitor_table amt
|
||||
on amt.APS_monitor_table_ID = amr.AMR_APS_monitor_table
|
||||
where amr.AMR_APS_TS BETWEEN '2024-08-27' AND '2024-08-27 23:59:59' /* Flag comme extrait */
|
||||
and amt.AMT_table_name = 'PH_item_regulation_info' /* Table en erreur */
|
||||
|
||||
/* AMR totaux */
|
||||
select amr.AMR_horizontal_extraction_TS, amr.AMR_aps_ts, amr.AMR_extraction_timestamp, amr.*
|
||||
from aps_monitor_row amr ( nolock)
|
||||
join APS_monitor_table amt
|
||||
on amt.APS_monitor_table_ID = amr.AMR_APS_monitor_table
|
||||
where amr.AMR_APS_TS BETWEEN '2024-08-27' AND '2024-08-27 23:59:59' /* Flag comme extrait */
|
||||
--and AMR_APS_monitor_table = 1817 /* Item_Key */
|
||||
|
||||
/* Délabéliser les monitor_row */
|
||||
update aps_monitor_row
|
||||
set AMR_horizontal_extraction_TS = null,
|
||||
AMR_extraction_timestamp = null
|
||||
where AMR_APS_TS BETWEEN '2024-08-27' AND '2024-08-27 23:59:59'
|
||||
and AMR_APS_monitor_table in (1817) /* Item_Key */ /* (334700 rows affected) */
|
||||
|
||||
/**************************/
|
||||
|
||||
/* Etapes de la synchro H (Step 3)*/
|
||||
begin transaction
|
||||
set xact_abort on
|
||||
|
||||
/*--- suppression du label si existant ---*/
|
||||
delete TT_extraction_timestamp
|
||||
where TTEXTS_horizontal_timestamp is not null
|
||||
|
||||
/*--- creation du label ---*/
|
||||
insert TT_extraction_timestamp
|
||||
(TTEXTS_horizontal_timestamp)
|
||||
values (getdate())
|
||||
|
||||
/* Pour info */
|
||||
SELECT * FROM TT_extraction_timestamp
|
||||
|
||||
/* Pour les tables qui ton une cle étrangere sur la table Item */
|
||||
/*------------- Remplissage par la succursale source --------------*/
|
||||
insert TT_Synchro_Item_List
|
||||
(TTSYNCIT_spid,
|
||||
TTSYNCIT_item_id,
|
||||
TTSYNCIT_item_key_id)
|
||||
select @@spid,
|
||||
itk.ITK_item,
|
||||
itk.Item_Key_id
|
||||
from item_key itk with (nolock)
|
||||
where itk.ITK_Type = 1
|
||||
and itk.ITK_subsidiary = 100--@param_source_subsidiary_id
|
||||
|
||||
/* Step 4 */
|
||||
/*-- recuperation du label --*/
|
||||
DECLARE @extraction_timestamp DATETIME;
|
||||
select top 1 @extraction_timestamp = TTEXTS_horizontal_timestamp
|
||||
from TT_extraction_timestamp (nolock)
|
||||
where TTEXTS_horizontal_timestamp is not NULL
|
||||
|
||||
SELECT @extraction_timestamp '@extraction_timestamp'
|
||||
|
||||
/*-- labelisation --*/
|
||||
Update amr
|
||||
set AMR_horizontal_extraction_TS = @extraction_timestamp
|
||||
from aps_monitor_row amr (nolock)
|
||||
join aps_monitor_table (nolock)
|
||||
on aps_monitor_table_id = amr_aps_monitor_table
|
||||
where AMR_horizontal_extraction_TS is null
|
||||
and AMT_horizontal_synchronization = 1
|
||||
and isnull(AMT_dynamic_synch_H, 0) = 1
|
||||
/** Fin du step 4 *******************************************/
|
||||
|
||||
/* Pour la SP aps_Sync_H_TT_AMR_Create, mettre a jour la colonne AMR_horizontal_extraction_TS */
|
||||
/* avec le extraction_timestamp */
|
||||
UPDATE dbo.APS_monitor_row
|
||||
SET AMR_horizontal_extraction_TS = @extraction_timestamp
|
||||
WHERE APS_monitor_row_ID IN(
|
||||
SELECT amr.APS_monitor_row_ID
|
||||
from aps_monitor_row amr ( nolock)
|
||||
join APS_monitor_table amt
|
||||
on amt.APS_monitor_table_ID = amr.AMR_APS_monitor_table
|
||||
where amr.AMR_APS_TS BETWEEN '2024-08-27' AND '2024-08-27 23:59:59'
|
||||
and AMR_APS_monitor_table in (1817)
|
||||
)
|
||||
|
||||
/* Step 5 */
|
||||
/* Passer une par une les differentes synchro de sub */
|
||||
/* SYNC - ITEM - H Synchronize items from 000 to CENT */
|
||||
declare @SubCENT INT,@SubSUN INT, @SubAMA int, @SubCVI int
|
||||
|
||||
SELECT @SubCENT = Subsidiary_ID FROM Arizona.dbo.Subsidiary WHERE SUB_code = '000'
|
||||
SELECT @SubSUN = Subsidiary_ID FROM Arizona.dbo.Subsidiary WHERE SUB_code = 'CENT'
|
||||
|
||||
exec aps_Sync_H_Item_Master
|
||||
@in_source_subsidiary_id = @SubCENT,
|
||||
@in_dest_subsidiary_id = @SubSUN,
|
||||
@in_dest_company_id = null,
|
||||
@in_AMR_usage = 1,
|
||||
@in_prc_code_excluded = 'PSUN; AUTO; CPUB; SPUB; FPUB; PDBR; XPUB; PPUB; ACTI; PROU;',
|
||||
@in_crt_code_excluded = 'PLC',
|
||||
@in_spid = @@spid,
|
||||
@in_extraction_timestamp = @extraction_timestamp
|
||||
,@in_debug = -5
|
||||
|
||||
|
||||
/* SYNC - ITEM - H Synchronize items from 000 to AMA */
|
||||
SELECT @SubCENT = Subsidiary_ID FROM Arizona.dbo.Subsidiary WHERE SUB_code = '000'
|
||||
SELECT @SubAMA = Subsidiary_ID FROM Arizona.dbo.Subsidiary WHERE SUB_code = 'AMA'
|
||||
|
||||
exec aps_Sync_H_Item_Master
|
||||
@in_source_subsidiary_id = @SubCENT,
|
||||
@in_dest_subsidiary_id = @SubAMA,
|
||||
@in_dest_company_id = null,
|
||||
@in_AMR_usage = 1,
|
||||
@in_prc_code_excluded = 'PSUN; AUTO; CPUB; SPUB; FPUB; PDBR; XPUB; PPUB; ACTI; PROU;',
|
||||
@in_crt_code_excluded = 'PLC',
|
||||
@in_spid = @@spid,
|
||||
@in_extraction_timestamp = @extraction_timestamp
|
||||
,@in_debug = -5
|
||||
|
||||
/* SYNC - ITEM - H Synchronize items from 000 to COOP */
|
||||
SELECT @SubCENT = Subsidiary_ID FROM Arizona.dbo.Subsidiary WHERE SUB_code = '000'
|
||||
SELECT @SubCVI = Subsidiary_ID FROM Arizona.dbo.Subsidiary WHERE SUB_code = 'COOP'
|
||||
|
||||
exec aps_Sync_H_Item_Master
|
||||
@in_source_subsidiary_id = @SubCENT,
|
||||
@in_dest_subsidiary_id = @SubCVI,
|
||||
@in_dest_company_id = null,
|
||||
@in_AMR_usage = 1,
|
||||
@in_prc_code_excluded = 'PSUN; AUTO; CPUB; SPUB; FPUB; PDBR; XPUB; PPUB; ACTI; PROU;',
|
||||
@in_crt_code_excluded = 'PLC',
|
||||
@in_spid = @@spid,
|
||||
@in_extraction_timestamp = @extraction_timestamp
|
||||
,@in_debug = -5
|
||||
|
||||
/*-- labelisation --*/
|
||||
/* SYNC - ITEM - Update AMR_horizontal_extraction_TS with label - End / STEP 10 */
|
||||
Update amr
|
||||
set AMR_horizontal_extraction_TS = @extraction_timestamp
|
||||
from aps_monitor_row amr (nolock)
|
||||
join aps_monitor_table (nolock)
|
||||
on aps_monitor_table_id = amr_aps_monitor_table
|
||||
where AMR_horizontal_extraction_TS is null
|
||||
and amt_horizontal_synchronization = 1
|
||||
|
||||
/*--- suppression du label si existant ---*/
|
||||
delete TT_extraction_timestamp
|
||||
where TTEXTS_horizontal_timestamp is not null
|
||||
|
||||
|
||||
--rollback transaction
|
||||
commit transaction
|
||||
56
GAIA - delete data from short aliases.sql
Normal file
56
GAIA - delete data from short aliases.sql
Normal file
@@ -0,0 +1,56 @@
|
||||
use Gaia
|
||||
|
||||
declare @toClean table(
|
||||
alias varchar(222) not null
|
||||
);
|
||||
|
||||
insert into @toClean(alias)
|
||||
select 'ama207'
|
||||
union select 'ama208'
|
||||
union select 'cvi243'
|
||||
union select 'cvi244'
|
||||
union select 'cvi245'
|
||||
union select 'cvi255'
|
||||
union select 'cvi269'
|
||||
union select 'cvi811'
|
||||
union select 'sun143'
|
||||
union select 'ama002'
|
||||
union select 'ama003'
|
||||
union select 'ama004'
|
||||
union select 'ama006'
|
||||
union select 'ama008'
|
||||
union select 'ama201'
|
||||
union select 'ama203'
|
||||
union select 'ama204'
|
||||
union select 'ama206'
|
||||
|
||||
;
|
||||
|
||||
/* PURGE OLD DATA */
|
||||
with ctePharmacyCode as (
|
||||
select phcy_code =
|
||||
case
|
||||
WHEN upper(left(alias,3)) = 'SUN' THEN 'GSU' + RIGHT(upper(alias),3)
|
||||
WHEN upper(left(alias,3)) = 'CVI' THEN 'GCV' + RIGHT(upper(alias),3)
|
||||
WHEN upper(left(alias,3)) = 'AMA' THEN 'GAM' + RIGHT(upper(alias),3)
|
||||
end
|
||||
from @toClean
|
||||
)
|
||||
, cteOneStringPharmacyCode as (
|
||||
select stuff(x.phcy_code,1,1,'') as concatenated_phcy_code
|
||||
from (
|
||||
select ','''+phcy_code+''''
|
||||
from ctePharmacyCode
|
||||
for xml path('')
|
||||
)x(phcy_code)
|
||||
)
|
||||
|
||||
SELECT 'DELETE FROM [' + s.name + '].[' + t.name + '] WHERE ' + c.name + ' IN (' + l.concatenated_phcy_code + ');' as delcmd
|
||||
FROM sys.schemas s
|
||||
JOIN sys.tables t ON t.schema_id = s.schema_id
|
||||
JOIN sys.columns c ON c.object_id = t.object_id AND c.name LIKE '%_pharmacy_code'
|
||||
cross join cteOneStringPharmacyCode l
|
||||
WHERE s.name = 'phar'
|
||||
ORDER BY t.name
|
||||
|
||||
|
||||
1230
HCI - BAG - sl2007_to_onprem publication.sql
Normal file
1230
HCI - BAG - sl2007_to_onprem publication.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
IF EXISTS (SELECT *
|
||||
FROM tempdb.sys.objects
|
||||
WHERE [name] LIKE '#WaitResources%')
|
||||
DROP TABLE #WaitResources;
|
||||
|
||||
CREATE TABLE #WaitResources
|
||||
(
|
||||
session_id INT,
|
||||
wait_type NVARCHAR (1000),
|
||||
wait_duration_ms INT,
|
||||
resource_description sysname NULL,
|
||||
db_name NVARCHAR (1000),
|
||||
schema_name NVARCHAR (1000),
|
||||
object_name NVARCHAR (1000),
|
||||
index_name NVARCHAR (1000)
|
||||
);
|
||||
GO
|
||||
|
||||
DECLARE @WaitDelay AS VARCHAR (16), @Counter AS INT, @MaxCount AS INT, @Counter2 AS INT;
|
||||
SELECT @Counter = 0, @MaxCount = 600, @WaitDelay = '00:00:00.100'; -- 600x.1=60 seconds
|
||||
|
||||
SET NOCOUNT ON;
|
||||
|
||||
WHILE @Counter < @MaxCount
|
||||
BEGIN
|
||||
INSERT INTO #WaitResources (session_id, wait_type, wait_duration_ms, resource_description)--, db_name, schema_name, object_name, index_name)
|
||||
SELECT wt.session_id,
|
||||
wt.wait_type,
|
||||
wt.wait_duration_ms,
|
||||
wt.resource_description
|
||||
FROM sys.dm_os_waiting_tasks AS wt
|
||||
WHERE wt.wait_type LIKE 'PAGELATCH%'
|
||||
AND wt.session_id <> @@SPID;
|
||||
|
||||
-- SELECT * FROM sys.dm_os_buffer_descriptors;
|
||||
|
||||
SET @Counter = @Counter + 1;
|
||||
WAITFOR DELAY @WaitDelay;
|
||||
END
|
||||
|
||||
--SELECT * FROM #WaitResources;
|
||||
|
||||
UPDATE #WaitResources
|
||||
SET db_name = DB_NAME(bd.database_id),
|
||||
schema_name = s.name,
|
||||
object_name = o.name,
|
||||
index_name = i.name
|
||||
FROM #WaitResources AS wt
|
||||
INNER JOIN sys.dm_os_buffer_descriptors AS bd
|
||||
ON bd.database_id = SUBSTRING(wt.resource_description, 0, CHARINDEX(':', wt.resource_description))
|
||||
AND bd.file_id = SUBSTRING(wt.resource_description, CHARINDEX(':', wt.resource_description) + 1, CHARINDEX(':', wt.resource_description, CHARINDEX(':', wt.resource_description) + 1) - CHARINDEX(':', wt.resource_description) - 1)
|
||||
AND bd.page_id = SUBSTRING(wt.resource_description, CHARINDEX(':', wt.resource_description, CHARINDEX(':', wt.resource_description) + 1) + 1, LEN(wt.resource_description) + 1)
|
||||
-- AND wt.file_index > 0 AND wt.page_index > 0
|
||||
INNER JOIN sys.allocation_units AS au
|
||||
ON bd.allocation_unit_id = AU.allocation_unit_id
|
||||
INNER JOIN sys.partitions AS p
|
||||
ON au.container_id = p.partition_id
|
||||
INNER JOIN sys.indexes AS i
|
||||
ON p.index_id = i.index_id
|
||||
AND p.object_id = i.object_id
|
||||
INNER JOIN sys.objects AS o
|
||||
ON i.object_id = o.object_id
|
||||
INNER JOIN sys.schemas AS s
|
||||
ON o.schema_id = s.schema_id;
|
||||
|
||||
SELECT * FROM #WaitResources
|
||||
ORDER BY wait_duration_ms DESC;
|
||||
GO
|
||||
/*
|
||||
--Other views of the same information
|
||||
SELECT wait_type, db_name, schema_name, object_name, index_name, SUM(wait_duration_ms) [total_wait_duration_ms] FROM #WaitResources
|
||||
GROUP BY wait_type, db_name, schema_name, object_name, index_name;
|
||||
SELECT session_id, wait_type, db_name, schema_name, object_name, index_name, SUM(wait_duration_ms) [total_wait_duration_ms] FROM #WaitResources
|
||||
GROUP BY session_id, wait_type, db_name, schema_name, object_name, index_name;
|
||||
*/
|
||||
|
||||
--SELECT * FROM #WaitResources
|
||||
--DROP TABLE #WaitResources;
|
||||
BIN
REPO - get auth.sql
Normal file
BIN
REPO - get auth.sql
Normal file
Binary file not shown.
Binary file not shown.
916
Ultimate Compression Savings Estimation Check.sql
Normal file
916
Ultimate Compression Savings Estimation Check.sql
Normal file
@@ -0,0 +1,916 @@
|
||||
----------------------------------------------------------------
|
||||
-------- Ultimate Compression Savings Estimation Check ---------
|
||||
----------------------------------------------------------------
|
||||
-- Author: Eitan Blumin | https://www.eitanblumin.com
|
||||
-- Create Date: 2019-12-08
|
||||
-- Source: http://bit.ly/SQLCompressionEstimation
|
||||
-- Full Link: https://gist.github.com/EitanBlumin/85cf620f7267b234d677f9c3027fb7ce
|
||||
-- GitHub Repo: https://github.com/MadeiraData/MadeiraToolbox/blob/master/Utility%20Scripts/ultimate_compression_savings_estimation_whole_database.sql
|
||||
-- Blog: https://eitanblumin.com/2020/02/18/ultimate-compression-savings-estimation-script-entire-database/
|
||||
----------------------------------------------------------------
|
||||
-- Description:
|
||||
-- ------------
|
||||
-- This script performs compression savings estimation check for both PAGE and ROW
|
||||
-- compression for an ENTIRE DATABASE.
|
||||
-- For each index which passes the check, a corresponding ALTER INDEX command
|
||||
-- is printed for you to use in order to apply the compression.
|
||||
-- The script also compares the results of the PAGE and ROW estimations and automatically
|
||||
-- selects the one with the better savings as the command to print, based on the provided thresholds.
|
||||
-- This script uses mathematical rounding functions FLOOR and CEILING in a manner which makes it more "cautious".
|
||||
--
|
||||
-- Some of the algorithms in this script were adapted from the following resources:
|
||||
-- https://www.sqlservercentral.com/blogs/introducing-what_to_compress-v2
|
||||
-- https://github.com/microsoft/tigertoolbox/tree/master/Evaluate-Compression-Gains
|
||||
-- https://github.com/microsoft/azure-sql-tips
|
||||
----------------------------------------------------------------
|
||||
-- Change Log:
|
||||
-- -----------
|
||||
-- 2024-06-20 - removed parameter @MinimumScanPctForComparison; removed singleton_lookup_count from calculation.
|
||||
-- 2021-09-09 - added check for incompatible options SortInTempDB and ResumableBuild being both enabled
|
||||
-- 2021-09-06 - added @ResumableRebuild parameter
|
||||
-- 2021-09-01 - some minor bug fixes and code quality fixes
|
||||
-- 2021-02-02 - added SET NOCOUNT, QUOTED_IDENTIFIER, ARITHABORT, XACT_ABORT ON settings
|
||||
-- 2021-01-17 - added cautionary parameters to stop/pause execution if CPU utilization is too high
|
||||
-- 2021-01-17 - added optional cautionary parameters controlling allowed/forbidden execution window
|
||||
-- 2021-01-17 - made some changes to threshold parameters based on partition stats (adapted from Azure-SQL-Tips)
|
||||
-- 2021-01-05 - added informative message about current TempDB available space
|
||||
-- 2020-12-06 - added @MaximumUpdatePctAsInfrequent and @MinimumScanPctForComparison parameters
|
||||
-- 2020-12-01 - output remediation script is now idempotent; fixed recommendations in resultset to match actual remediation script
|
||||
-- 2020-09-30 - added @MaxDOP parameter
|
||||
-- 2020-09-06 - added support for readable secondaries; added MAXDOP 1 for the query from operational stats to avoid access violation bug
|
||||
-- 2020-03-30 - added filter to ignore indexes and tables with unsupported LOB/FILESTREAM columns
|
||||
-- 2020-03-16 - added informational and status messages in output script
|
||||
-- 2020-03-15 - tweaked default parameter values a bit; added server uptime message
|
||||
-- 2020-02-26 - added best guess for unknown compression recommendations; improved performance for DBs with many objects
|
||||
-- 2020-02-19 - added support for Azure SQL DB
|
||||
-- 2020-02-18 - cleaned the code a bit and fixed some bugs
|
||||
-- 2020-02-17 - added specific database support; adjusted tabs to match github standard; added compatibility checks
|
||||
-- 2020-02-16 - added threshold parameters; additional checks based on partition stats and operational stats
|
||||
-- 2019-12-09 - added ONLINE rebuild option
|
||||
-- 2019-12-24 - flipped to traditional ratio calculation; added READ UNCOMMITTED isolation level; added minimum difference thresholds for PAGE vs. ROW considerations
|
||||
----------------------------------------------------------------
|
||||
--
|
||||
-- IMPORTANT !!!
|
||||
-- -------------
|
||||
--
|
||||
-- 1. Don't forget to change the @DatabaseName parameter value to the one you want to check.
|
||||
--
|
||||
-- 2. BE MINDFUL IN PRODUCTION ENVIRONMENTS !
|
||||
--
|
||||
-- - If you want to be extra careful, run this script with @FeasibilityCheckOnly set to 1. This will perform only basic checks for compression candidates
|
||||
-- based on usage and operational stats only, without running [sp_estimate_data_compression_savings].
|
||||
--
|
||||
-- - Running this script with @FeasibilityCheckOnly = 0 may take a very long time on big databases with many tables, and significant IO + CPU stress may be noticeable.
|
||||
--
|
||||
-- - Schema-level locks may be held for a while per each table, and will possibly block other sessions performing DDL operations.
|
||||
--
|
||||
-- - This script uses [sp_estimate_data_compression_savings] which copies 5 % of your data into TempDB and compresses it there.
|
||||
-- If you have very large tables, you must be very careful not to fill out the disk.
|
||||
-- Please use the following cautionary threshold parameters to avoid such scenarios: @MaxSizeMBForActualCheck, @TempDBSpaceUsageThresholdPercent
|
||||
----------------------------------------------------------------
|
||||
-- Parameters:
|
||||
-- -----------
|
||||
DECLARE
|
||||
-- Choose what to check:
|
||||
@DatabaseName SYSNAME = NULL -- Specify the name of the database to check. If NULL, will use current.
|
||||
,@FeasibilityCheckOnly BIT = 1 -- If 1, will only check for potential compression candidates, without using sp_estimate_data_compression_savings and without generating remediation scripts
|
||||
,@CheckPerPartition BIT = 0 -- If 1, will perform separate estimation checks per partition
|
||||
,@MinimumSizeMB INT = 256 -- Minimum table/partition size in MB in order to perform estimation checks on it
|
||||
|
||||
-- Cautionary thresholds:
|
||||
,@MaxSizeMBForActualCheck INT = NULL -- If a table/partition is bigger than this size (in MB), then sp_estimate_data_compression_savings will NOT be executed for it. If set to NULL, then use available TempDB space instead
|
||||
,@TempDBSpaceUsageThresholdPercent INT = 60 -- A percentage number between 1 and 100, representing how much of the disk space available to TempDB is allowed to be used for the estimation checks
|
||||
|
||||
-- Cautionary parameters to stop/pause execution if CPU utilization is too high (this affects both the estimation check and the rebuild script):
|
||||
,@MaximumCPUPercentForRebuild INT = 80 -- Maximum average CPU utilization to allow rebuild. Set to NULL to ignore.
|
||||
,@SamplesToCheckAvgForCPUPercent INT = 10 -- Number of CPU utilization percent samples to check and average out
|
||||
,@MaximumTimeToWaitForCPU DATETIME = '00:10:00' -- Maximum time to continously wait for CPU utilization to drop below threshold, before cancelling execution (HH:MM:SS.MS format). Set to NULL to wait forever.
|
||||
|
||||
-- Optional cautionary parameters controlling allowed execution window (server clock)
|
||||
-- You can think of this as your "maintenance window" (24hour based. for example, between 0 and 4):
|
||||
,@AllowedRuntimeHourFrom INT = NULL -- If not NULL, will specify minimum hour of day during which rebuilds are allowed
|
||||
,@AllowedRuntimeHourTo INT = NULL -- If not NULL, will specify maximum hour of day during which rebuilds are allowed
|
||||
|
||||
-- Optional cautionary parameters controlling forbidden execution window (server clock)
|
||||
-- You can think of this as your "business hours" (24hour based. for example, between 6 and 22):
|
||||
,@NotAllowedRuntimeHourFrom INT = 6 -- If not NULL, will specify minimum time of day during which rebuilds are forbidden
|
||||
,@NotAllowedRuntimeHourTo INT = 22 -- If not NULL, will specify maximum time of day during which rebuilds are forbidden
|
||||
|
||||
-- Threshold parameters controlling recommendation algorithms based on partition stats:
|
||||
,@MinimumCompressibleDataPercent INT = 45 -- Minimum percent of compressible in-row data, in order to consider any compression
|
||||
,@MaximumUpdatePctAsInfrequent INT = 10 -- Maximum percent of updates for all operations to consider as "infrequent updates"
|
||||
,@MinimumScanPctForPage INT = 40 -- Minimum percent of scans when comparing to update percent, to deem PAGE compression preferable (otherwise, ROW compression will be preferable)
|
||||
,@MaximumUpdatePctForPage INT = 40 -- Maximum percent of updates when comparing to scan percent, to deem PAGE compression preferable
|
||||
,@MaximumUpdatePctForRow INT = 60 -- Maximum percent of updates when comparing to scan percent, to deem ROW compression preferable
|
||||
|
||||
-- Threshold parameters controlling recommendation algorithms based on savings estimation check:
|
||||
,@CompressionRatioThreshold FLOAT = 45 -- Number between 0 and 100 representing the minimum compressed data ratio, relative to current size, for which a check will pass
|
||||
,@CompressionSizeSavedMBThreshold FLOAT = 200 -- Minimum estimated saved space in MB resulting from compression (affects both PAGE and ROW compressions)
|
||||
,@MinimumRatioDifferenceForPage FLOAT = 20 -- Minimum difference in percentage between ROW and PAGE compression types, in order to deem PAGE compression preferable
|
||||
,@MinimumSavingsMBDifferenceForPage FLOAT = 40 -- Minimum difference in saved space in MB between ROW and PAGE compression types, in order to deem PAGE compression preferable
|
||||
|
||||
-- Parameters controlling the structure of output scripts:
|
||||
,@OnlineRebuild BIT = 1 -- If 1, will generate REBUILD commands with the ONLINE option turned on
|
||||
,@ResumableRebuild BIT = 0 -- If 1, will generate REBUILD commands with the RESUMABLE option turned on (SQL 2019 and newer only)
|
||||
,@SortInTempDB BIT = 1 -- If 1, will generate REBUILD commands with the SORT_IN_TEMPDB option turned on. Incompatible with RESUMABLE=ON.
|
||||
,@MaxDOP INT = NULL -- If not NULL, will add a MaxDOP option accordingly. Set to 1 to prevent parallelism and reduce workload.
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- DO NOT CHANGE ANYTHING BELOW THIS LINE --
|
||||
--------------------------------------------------------------------
|
||||
|
||||
SET NOCOUNT, ARITHABORT, XACT_ABORT ON;
|
||||
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
|
||||
|
||||
-- Variable declaration
|
||||
DECLARE @CMD NVARCHAR(MAX), @AvailableTempDBSpaceMB INT, @ErrMsg NVARCHAR(MAX)
|
||||
DECLARE @CurrDB SYSNAME, @Schema SYSNAME, @Table SYSNAME, @ObjectId INT, @IndexId INT, @IndexName SYSNAME, @Partition INT, @CompressionType VARCHAR(4), @EstimationCheckRecommended BIT, @TotalSizeMB INT, @InRowPercent INT, @ScanPercent INT, @UpdatePercent INT
|
||||
DECLARE @Results AS TABLE ([object_name] SYSNAME NOT NULL, [schema_name] SYSNAME NOT NULL, index_id int NULL, partition_number int NULL, size_w_current_compression_KB float NULL, size_w_requested_compression_KB float NULL, sample_size_current_KB int NULL, sample_size_requested_KB int NULL)
|
||||
DECLARE @RebuildOptions NVARCHAR(MAX), @ChecksSkipped BIT
|
||||
|
||||
-- Compatibility checks
|
||||
SELECT @ErrMsg = ISNULL(@ErrMsg + ', ', N'Sorry, this SQL Server version is not supported. Missing object(s): ') + objectname
|
||||
FROM (
|
||||
SELECT objectname = CONVERT(nvarchar(500), 'sys.tables')
|
||||
UNION ALL SELECT 'sys.dm_os_volume_stats' WHERE CONVERT(varchar(300),SERVERPROPERTY('Edition')) <> 'SQL Azure'
|
||||
UNION ALL SELECT 'sys.master_files' WHERE CONVERT(varchar(300),SERVERPROPERTY('Edition')) <> 'SQL Azure'
|
||||
UNION ALL SELECT 'sys.dm_db_index_operational_stats'
|
||||
UNION ALL SELECT 'sys.dm_db_partition_stats'
|
||||
UNION ALL SELECT 'sys.sp_estimate_data_compression_savings'
|
||||
UNION ALL SELECT 'sys.indexes'
|
||||
UNION ALL SELECT 'sys.partitions') AS t
|
||||
WHERE OBJECT_ID(objectname) IS NULL;
|
||||
|
||||
IF @ErrMsg IS NOT NULL
|
||||
BEGIN
|
||||
RAISERROR(@ErrMsg,16,1)
|
||||
GOTO Quit;
|
||||
END
|
||||
|
||||
-- Init local variables and defaults
|
||||
SET @RebuildOptions = N''
|
||||
IF @ResumableRebuild = 1 SET @OnlineRebuild = 1;
|
||||
IF @OnlineRebuild = 1 SET @RebuildOptions = @RebuildOptions + N', ONLINE = ON'
|
||||
IF @ResumableRebuild = 1 SET @RebuildOptions = @RebuildOptions + N', RESUMABLE = ON'
|
||||
IF @SortInTempDB = 1 SET @RebuildOptions = @RebuildOptions + N', SORT_IN_TEMPDB = ON'
|
||||
IF @MaxDOP IS NOT NULL SET @RebuildOptions = @RebuildOptions + N', MAXDOP = ' + CONVERT(nvarchar(4000), @MaxDOP)
|
||||
SET @ChecksSkipped = 0;
|
||||
SET @FeasibilityCheckOnly = ISNULL(@FeasibilityCheckOnly, 1)
|
||||
|
||||
-- Check for incompatible options
|
||||
IF @SortInTempDB = 1 AND @ResumableRebuild = 1
|
||||
BEGIN
|
||||
RAISERROR(N'SORT_IN_TEMPDB and RESUMABLE are incompatible options. Please pick only one of them.',16,1)
|
||||
GOTO Quit;
|
||||
END
|
||||
|
||||
-- Validate mandatory percentage parameters
|
||||
SELECT @ErrMsg = ISNULL(@ErrMsg + CHAR(10), N'Invalid parameter(s): ') + CONVERT(nvarchar(max), N'' + VarName + N' must be a value between 1 and 100')
|
||||
FROM
|
||||
(VALUES
|
||||
('@MinimumCompressibleDataPercent',@MinimumCompressibleDataPercent)
|
||||
,('@MinimumScanPctForPage',@MinimumScanPctForPage)
|
||||
,('@MaximumUpdatePctForPage',@MaximumUpdatePctForPage)
|
||||
,('@MaximumUpdatePctForRow',@MaximumUpdatePctForRow)
|
||||
,('@TempDBSpaceUsageThresholdPercent',@TempDBSpaceUsageThresholdPercent)
|
||||
,('@CompressionRatioThreshold',@CompressionRatioThreshold)
|
||||
,('@MinimumRatioDifferenceForPage',@MinimumRatioDifferenceForPage)
|
||||
,('@MaximumUpdatePctAsInfrequent',@MaximumUpdatePctAsInfrequent)
|
||||
,('@MaximumCPUPercentForRebuild',ISNULL(@MaximumCPUPercentForRebuild,100))
|
||||
) AS v(VarName,VarValue)
|
||||
WHERE VarValue NOT BETWEEN 1 AND 100 OR VarValue IS NULL
|
||||
OPTION (RECOMPILE);
|
||||
|
||||
IF @ErrMsg IS NOT NULL
|
||||
BEGIN
|
||||
RAISERROR(@ErrMsg,16,1);
|
||||
GOTO Quit;
|
||||
END
|
||||
|
||||
-- Validate hour-based parameters
|
||||
SELECT @ErrMsg = ISNULL(@ErrMsg + CHAR(10), N'Invalid parameter(s): ') + CONVERT(nvarchar(max), N'' + VarName + N' must be a value between 0 and 23')
|
||||
FROM
|
||||
(VALUES
|
||||
('@AllowedRuntimeHourFrom',@AllowedRuntimeHourFrom)
|
||||
,('@AllowedRuntimeHourTo',@AllowedRuntimeHourTo)
|
||||
,('@NotAllowedRuntimeHourFrom',@NotAllowedRuntimeHourFrom)
|
||||
,('@NotAllowedRuntimeHourTo',@NotAllowedRuntimeHourTo)
|
||||
) AS v(VarName,VarValue)
|
||||
WHERE VarValue NOT BETWEEN 0 AND 23 AND VarValue IS NOT NULL
|
||||
OPTION (RECOMPILE);
|
||||
|
||||
IF @ErrMsg IS NOT NULL
|
||||
BEGIN
|
||||
RAISERROR(@ErrMsg,16,1);
|
||||
GOTO Quit;
|
||||
END
|
||||
|
||||
IF @FeasibilityCheckOnly = 0 AND CONVERT(varchar(300),SERVERPROPERTY('Edition')) <> 'SQL Azure'
|
||||
BEGIN
|
||||
-- Check free space remaining for TempDB
|
||||
SET @CMD = N'USE tempdb;
|
||||
SELECT @AvailableTempDBSpaceMB = SUM(ISNULL(available_space_mb,0)) FROM
|
||||
(
|
||||
-- Get available space inside data files
|
||||
SELECT
|
||||
vs.volume_mount_point
|
||||
, available_space_mb = SUM(ISNULL(f.size - FILEPROPERTY(f.[name], ''SpaceUsed''),0)) / 128
|
||||
+ SUM(CASE
|
||||
-- If auto growth is disabled
|
||||
WHEN f.max_size = 0 THEN 0
|
||||
-- If remaining growth size is smaller than remaining disk space, use remaining growth size till max size
|
||||
WHEN f.max_size > 0 AND (f.max_size - f.size) / 128 < (vs.available_bytes / 1024 / 1024) THEN (f.max_size - f.size) / 128
|
||||
-- Else, do not count available growth for this file
|
||||
ELSE 0
|
||||
END)
|
||||
FROM sys.master_files AS f
|
||||
CROSS APPLY sys.dm_os_volume_stats (f.database_id, f.file_id) AS vs
|
||||
WHERE f.database_id = 2
|
||||
AND f.type = 0
|
||||
GROUP BY vs.volume_mount_point
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- Get available space on disk for auto-growth
|
||||
SELECT
|
||||
vs.volume_mount_point
|
||||
, available_space_mb = vs.available_bytes / 1024 / 1024
|
||||
FROM sys.master_files AS f
|
||||
CROSS APPLY sys.dm_os_volume_stats (f.database_id, f.file_id) AS vs
|
||||
WHERE f.database_id = 2
|
||||
AND f.type = 0
|
||||
-- If max size is unlimited, or difference between current size and max size is bigger than available disk space
|
||||
AND (f.max_size = -1 OR (f.max_size > 0 AND (f.max_size - f.size) / 128 > (vs.available_bytes / 1024 / 1024)))
|
||||
GROUP BY vs.volume_mount_point, vs.available_bytes
|
||||
) AS q OPTION (RECOMPILE);'
|
||||
|
||||
EXEC sp_executesql @CMD, N'@AvailableTempDBSpaceMB INT OUTPUT', @AvailableTempDBSpaceMB OUTPUT
|
||||
|
||||
-- Use @TempDBSpaceUsageThresholdPercent as a cautionary multiplier
|
||||
SET @AvailableTempDBSpaceMB = @AvailableTempDBSpaceMB * 1.0 * (@TempDBSpaceUsageThresholdPercent / 100.0)
|
||||
|
||||
IF @MaxSizeMBForActualCheck > FLOOR(@AvailableTempDBSpaceMB / 0.05)
|
||||
BEGIN
|
||||
RAISERROR(N'ALERT: %d percent of available TempDB Disk Space is less than 5 percent of specified @MaxSizeMBForActualCheck (%d). Please adjust @MaxSizeMBForActualCheck and/or @TempDBSpaceUsageThresholdPercent accordingly.', 16, 1, @TempDBSpaceUsageThresholdPercent, @MaxSizeMBForActualCheck);
|
||||
GOTO Quit;
|
||||
END
|
||||
ELSE IF ISNULL(@MaxSizeMBForActualCheck,0) <= 0 -- If @MaxSizeMBForActualCheck was not specified, use available TempDB space instead
|
||||
SET @MaxSizeMBForActualCheck = FLOOR(@AvailableTempDBSpaceMB / 0.05);
|
||||
|
||||
RAISERROR(N'-- TempDB Free Disk Space: %d MB, max size for check: %d MB',0,1,@AvailableTempDBSpaceMB, @MaxSizeMBForActualCheck) WITH NOWAIT;
|
||||
END
|
||||
|
||||
IF @OnlineRebuild = 1 AND ISNULL(CONVERT(int, SERVERPROPERTY('EngineEdition')),0) NOT IN (3,5,8)
|
||||
BEGIN
|
||||
RAISERROR(N'-- WARNING: @OnlineRebuild is set to 1, but current SQL edition does not support ONLINE rebuilds.', 0, 1);
|
||||
END
|
||||
|
||||
IF @ResumableRebuild = 1 AND CONVERT(int, (@@microsoftversion / 0x1000000) & 0xff) < 15
|
||||
BEGIN
|
||||
RAISERROR(N'-- WARNING: @ResumableRebuild is set to 1, but current SQL version does not support RESUMABLE rebuilds.', 0, 1);
|
||||
END
|
||||
|
||||
DECLARE @ObjectsToCheck AS TABLE
|
||||
(
|
||||
[database_name] SYSNAME NOT NULL,
|
||||
[schema_name] SYSNAME NOT NULL,
|
||||
[table_id] int NULL,
|
||||
[table_name] SYSNAME NULL,
|
||||
[index_id] INT NULL,
|
||||
[index_name] SYSNAME NULL,
|
||||
[partition_number] INT NULL,
|
||||
size_MB INT NULL,
|
||||
in_row_percent INT NULL,
|
||||
range_scans_percent INT NULL,
|
||||
updates_percent INT NULL
|
||||
);
|
||||
|
||||
-- The following code, making use of @CurrDB variable, is written in a way which would make
|
||||
-- it easier to rewrite so that it can check multiple databases
|
||||
/* start of potential for-each-db */
|
||||
SET @CurrDB = ISNULL(@DatabaseName, DB_NAME())
|
||||
PRINT N'------------------------------------------------------------------------------------'
|
||||
PRINT N'------------- Compression Savings Estimation Check by Eitan Blumin -----------------'
|
||||
PRINT N'---------------- Source: http://bit.ly/SQLCompressionEstimation --------------------'
|
||||
PRINT N'------------------------------------------------------------------------------------'
|
||||
PRINT N'--- for Server: ' + @@SERVERNAME + N' , Database: ' + QUOTENAME(@CurrDB)
|
||||
PRINT N'------------------------------------------------------------------------------------'
|
||||
|
||||
DECLARE @SqlStartTime DATETIME, @UpTimeDays INT, @SqlStartTimeString VARCHAR(25);
|
||||
SELECT @SqlStartTime = sqlserver_start_time FROM sys.dm_os_sys_info;
|
||||
SET @UpTimeDays = DATEDIFF(dd, @SqlStartTime, GETDATE())
|
||||
SET @SqlStartTimeString = CONVERT(varchar(25), @SqlStartTime, 121)
|
||||
|
||||
RAISERROR(N'--- SQL Server is operational since %s (~%d days)', 0, 1, @SqlStartTimeString, @UpTimeDays) WITH NOWAIT;
|
||||
|
||||
-- Check whether TempDB is located on same disk as specified database
|
||||
IF @SortInTempDB = 1 AND CONVERT(varchar(300),SERVERPROPERTY('Edition')) <> 'SQL Azure'
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT fs.volume_mount_point
|
||||
FROM sys.master_files AS df
|
||||
CROSS APPLY sys.dm_os_volume_stats(df.database_id, df.file_id) AS fs
|
||||
WHERE df.type = 0
|
||||
AND df.database_id = DB_ID(@CurrDB)
|
||||
|
||||
INTERSECT
|
||||
|
||||
SELECT fs.volume_mount_point
|
||||
FROM sys.master_files AS df
|
||||
CROSS APPLY sys.dm_os_volume_stats(df.database_id, df.file_id) AS fs
|
||||
WHERE df.type = 0
|
||||
AND df.database_id = 2
|
||||
)
|
||||
RAISERROR(N'-- WARNING: @SortInTempDB is set to 1, but TempDB is located on the same disk drive as specified database "%s".', 0, 1, @CurrDB);
|
||||
END
|
||||
|
||||
-- Make sure specified database is accessible
|
||||
IF DB_ID(@CurrDB) IS NULL OR DATABASEPROPERTYEX(@CurrDB, 'Updateability') <> 'READ_WRITE' OR DATABASEPROPERTYEX(@CurrDB, 'Status') <> 'ONLINE'
|
||||
BEGIN
|
||||
IF @FeasibilityCheckOnly = 0 OR DB_ID(@CurrDB) IS NULL OR DATABASEPROPERTYEX(@CurrDB, 'Status') <> 'ONLINE'
|
||||
BEGIN
|
||||
RAISERROR(N'Database "%s" is not valid for compression estimation check. Please make sure it is accessible and writeable.',16,1,@CurrDB);
|
||||
GOTO Quit;
|
||||
END
|
||||
ELSE
|
||||
RAISERROR(N'-- NOTE: Database "%s" is not writeable. You will not be able to rebuild its indexes here until it is writeable.',10,1,@CurrDB);
|
||||
END
|
||||
|
||||
-- Get list of all un-compressed tables/partitions in the specified database
|
||||
-- Use a temp table in order to improve performance for databases with many tables
|
||||
SET @CMD = N'USE ' + QUOTENAME(@CurrDB) + N';
|
||||
IF OBJECT_ID(''tempdb..#objects'') IS NOT NULL DROP TABLE #objects;
|
||||
CREATE TABLE #objects
|
||||
(
|
||||
[schema_name] SYSNAME
|
||||
, [object_id] INT
|
||||
, [table_name] SYSNAME
|
||||
, [index_id] INT NULL
|
||||
, [index_name] SYSNAME NULL
|
||||
, [partition_number] INT NULL
|
||||
, [size_MB] INT
|
||||
, [in_row_percent] INT
|
||||
);
|
||||
|
||||
INSERT INTO #objects
|
||||
SELECT
|
||||
OBJECT_SCHEMA_NAME(t.object_id)
|
||||
, t.object_id
|
||||
, t.name
|
||||
, p.index_id
|
||||
, ix.name
|
||||
, partition_number = ' + CASE WHEN @CheckPerPartition = 1 THEN N'p.partition_number' ELSE N'NULL' END + N'
|
||||
, size_MB = CEILING(SUM(ISNULL(sps.in_row_data_page_count,0) + ISNULL(sps.row_overflow_used_page_count,0) + ISNULL(sps.lob_reserved_page_count,0)) / 128.0)
|
||||
, in_row_percent = ISNULL(
|
||||
FLOOR(SUM(ISNULL(sps.in_row_data_page_count,0)) * 1.0
|
||||
/ NULLIF(SUM(ISNULL(sps.in_row_data_page_count,0) + ISNULL(sps.row_overflow_used_page_count,0) + ISNULL(sps.lob_reserved_page_count,0)),0)
|
||||
* 100.0), 0)
|
||||
FROM sys.tables AS t WITH(NOLOCK)
|
||||
INNER JOIN sys.partitions AS p WITH(NOLOCK) ON t.object_id = p.object_id AND p.data_compression = 0
|
||||
INNER JOIN sys.indexes AS ix WITH(NOLOCK) ON ix.object_id = t.object_id AND ix.index_id = p.index_id
|
||||
LEFT JOIN sys.dm_db_partition_stats AS sps WITH(NOLOCK) ON sps.partition_id = p.partition_id
|
||||
WHERE
|
||||
-- Ignore system objects
|
||||
t.is_ms_shipped = 0
|
||||
AND t.object_id > 255
|
||||
AND OBJECT_SCHEMA_NAME(t.object_id) <> ''sys''
|
||||
-- Ignore indexes or tables with unsupported LOB/FILESTREAM columns
|
||||
AND NOT EXISTS
|
||||
(
|
||||
SELECT NULL
|
||||
FROM sys.columns AS c
|
||||
INNER JOIN sys.types AS t
|
||||
ON c.system_type_id = t.system_type_id
|
||||
AND c.user_type_id = t.user_type_id
|
||||
LEFT JOIN sys.index_columns AS ixc
|
||||
ON ixc.object_id = c.object_id
|
||||
AND ixc.column_id = c.column_id
|
||||
AND ix.index_id = ixc.index_id
|
||||
WHERE (t.[name] in (''text'', ''ntext'', ''image'') OR c.is_filestream = 1)
|
||||
AND ix.object_id = c.object_id
|
||||
AND (ix.index_id IN (0,1) OR ixc.index_id IS NOT NULL)
|
||||
)
|
||||
GROUP BY
|
||||
t.object_id
|
||||
, t.name
|
||||
, p.index_id
|
||||
, ix.name'
|
||||
+ CASE WHEN @CheckPerPartition = 1 THEN N', p.partition_number' ELSE '' END
|
||||
+ CASE WHEN ISNULL(@MinimumSizeMB,0) > 0 THEN N'
|
||||
HAVING
|
||||
CEILING(SUM(ISNULL(sps.in_row_data_page_count,0) + ISNULL(sps.row_overflow_used_page_count,0) + ISNULL(sps.lob_reserved_page_count,0)) / 128.0) >= ' + CONVERT(nvarchar(MAX), @MinimumSizeMB)
|
||||
ELSE N'' END + N'
|
||||
OPTION (RECOMPILE);
|
||||
|
||||
SELECT
|
||||
DB_NAME()
|
||||
, p.[schema_name]
|
||||
, p.object_id
|
||||
, p.table_name
|
||||
, p.index_id
|
||||
, p.index_name
|
||||
, p.partition_number
|
||||
, p.size_MB
|
||||
, p.in_row_percent
|
||||
, range_scans_percent = ISNULL(
|
||||
FLOOR(SUM(ISNULL(ios.range_scan_count,0)) * 1.0 /
|
||||
NULLIF(SUM(
|
||||
ISNULL(ios.range_scan_count,0) +
|
||||
ISNULL(ios.leaf_delete_count,0) +
|
||||
ISNULL(ios.leaf_insert_count,0) +
|
||||
ISNULL(ios.leaf_page_merge_count,0) +
|
||||
ISNULL(ios.leaf_update_count,0)
|
||||
), 0) * 100.0), 0)
|
||||
, updates_percent = ISNULL(
|
||||
CEILING(SUM(ISNULL(ios.leaf_update_count, 0)) * 1.0 /
|
||||
NULLIF(SUM(
|
||||
ISNULL(ios.range_scan_count,0) +
|
||||
ISNULL(ios.leaf_delete_count,0) +
|
||||
ISNULL(ios.leaf_insert_count,0) +
|
||||
ISNULL(ios.leaf_page_merge_count,0) +
|
||||
ISNULL(ios.leaf_update_count,0)
|
||||
), 0) * 100.0), 0)
|
||||
FROM #objects AS p WITH(NOLOCK)
|
||||
OUTER APPLY sys.dm_db_index_operational_stats(db_id(),p.object_id,p.index_id,p.partition_number) AS ios
|
||||
GROUP BY
|
||||
p.object_id
|
||||
, p.schema_name
|
||||
, p.table_name
|
||||
, p.index_id
|
||||
, p.index_name
|
||||
, p.partition_number
|
||||
, p.size_MB
|
||||
, p.in_row_percent
|
||||
OPTION (RECOMPILE, MAXDOP 1);'
|
||||
|
||||
INSERT INTO @ObjectsToCheck
|
||||
EXEC sp_executesql @CMD;
|
||||
|
||||
/* end of potential for-each-db */
|
||||
|
||||
-- Init temp table to hold final results
|
||||
IF OBJECT_ID('tempdb..#ResultsAll') IS NOT NULL DROP TABLE #ResultsAll;
|
||||
CREATE TABLE #ResultsAll (
|
||||
[database_name] SYSNAME NOT NULL
|
||||
, [schema_name] SYSNAME NOT NULL
|
||||
, [table_name] SYSNAME NOT NULL
|
||||
, [index_name] SYSNAME NULL
|
||||
, partition_number INT NULL
|
||||
, size_MB INT NULL
|
||||
, in_row_percent INT NULL
|
||||
, scan_percent INT NULL
|
||||
, update_percent INT NULL
|
||||
, compression_type VARCHAR(4) NOT NULL
|
||||
, compression_ratio FLOAT NULL
|
||||
, compression_size_saving_KB FLOAT NULL
|
||||
, is_compression_feasible BIT NULL
|
||||
, is_compression_recommended bit NULL
|
||||
)
|
||||
|
||||
-- Init cursor to traverse all un-compressed tables that were found
|
||||
DECLARE TablesToCheck CURSOR
|
||||
LOCAL FORWARD_ONLY FAST_FORWARD
|
||||
FOR
|
||||
SELECT
|
||||
o.[database_name]
|
||||
, o.[schema_name]
|
||||
, o.[table_id]
|
||||
, o.[table_name]
|
||||
, o.[index_id]
|
||||
, o.[index_name]
|
||||
, o.[partition_number]
|
||||
, ct.CompressionType
|
||||
, o.size_MB
|
||||
, o.in_row_percent
|
||||
, o.range_scans_percent
|
||||
, o.updates_percent
|
||||
FROM @ObjectsToCheck AS o
|
||||
CROSS JOIN (VALUES('PAGE'),('ROW')) AS ct(CompressionType) -- check both ROW and PAGE compression for each
|
||||
|
||||
OPEN TablesToCheck
|
||||
|
||||
FETCH NEXT FROM TablesToCheck
|
||||
INTO @CurrDB, @Schema, @ObjectId, @Table, @IndexId, @IndexName, @Partition, @CompressionType, @TotalSizeMB, @InRowPercent, @ScanPercent, @UpdatePercent
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
DECLARE @sp_estimate_data_compression_savings NVARCHAR(1000);
|
||||
SET @sp_estimate_data_compression_savings = QUOTENAME(@CurrDB) + '.sys.sp_estimate_data_compression_savings'
|
||||
|
||||
SET @EstimationCheckRecommended = CASE
|
||||
WHEN @InRowPercent < @MinimumCompressibleDataPercent THEN 0
|
||||
WHEN ISNULL(@UpdatePercent,0) <= @MaximumUpdatePctAsInfrequent THEN 1
|
||||
WHEN @CompressionType = 'PAGE' AND @ScanPercent >= @MinimumScanPctForPage AND @UpdatePercent <= @MaximumUpdatePctForPage THEN 1
|
||||
WHEN @CompressionType = 'ROW' AND @UpdatePercent <= @MaximumUpdatePctForRow THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
|
||||
RAISERROR(N'--Database [%s], table [%s].[%s], index [%s], partition %d: size: %d MB, in-row data: %d percent, range scans: %d percent, updates: %d percent. Compression type: %s',0,1
|
||||
,@CurrDB,@Schema,@Table,@IndexName,@Partition,@TotalSizeMB,@InRowPercent,@ScanPercent,@UpdatePercent,@CompressionType) WITH NOWAIT;
|
||||
|
||||
IF @FeasibilityCheckOnly = 0 AND (@MaxSizeMBForActualCheck IS NULL OR (@TotalSizeMB <= @MaxSizeMBForActualCheck AND @TotalSizeMB * 0.05 < @AvailableTempDBSpaceMB))
|
||||
BEGIN
|
||||
IF @EstimationCheckRecommended = 1
|
||||
BEGIN
|
||||
BEGIN TRY
|
||||
|
||||
IF @MaximumCPUPercentForRebuild IS NOT NULL
|
||||
BEGIN
|
||||
DECLARE @AvgCPU FLOAT, @WaitForCPUStartTime DATETIME;
|
||||
|
||||
CpuUtilizationCheck:
|
||||
SELECT @AvgCPU = AVG( 100 - record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') )
|
||||
FROM (
|
||||
SELECT TOP (@SamplesToCheckAvgForCPUPercent) [timestamp], convert(xml, record) as record
|
||||
FROM sys.dm_os_ring_buffers
|
||||
WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR'
|
||||
AND record like '%<SystemHealth>%'
|
||||
ORDER BY [timestamp] DESC
|
||||
) as RingBufferInfo
|
||||
|
||||
IF @AvgCPU <= @MaximumCPUPercentForRebuild
|
||||
BEGIN
|
||||
SET @WaitForCPUStartTime = NULL;
|
||||
GOTO AfterCpuUtilizationCheck;
|
||||
END
|
||||
ELSE IF @MaximumTimeToWaitForCPU IS NOT NULL
|
||||
BEGIN
|
||||
IF @WaitForCPUStartTime IS NULL
|
||||
BEGIN
|
||||
SET @WaitForCPUStartTime = GETDATE()
|
||||
END
|
||||
ELSE IF @WaitForCPUStartTime + @MaximumTimeToWaitForCPU > GETDATE()
|
||||
BEGIN
|
||||
RAISERROR(N'-- CPU utilization is too high. Aborting check.', 16, 1);
|
||||
GOTO EndOfCursor;
|
||||
END
|
||||
END
|
||||
|
||||
WAITFOR DELAY '00:00:00.5'
|
||||
GOTO CpuUtilizationCheck;
|
||||
END
|
||||
AfterCpuUtilizationCheck:
|
||||
|
||||
-- Calculate compression savings estimation
|
||||
INSERT INTO @Results
|
||||
EXEC @sp_estimate_data_compression_savings
|
||||
@schema_name = @Schema,
|
||||
@object_name = @Table,
|
||||
@index_id = @IndexId,
|
||||
@partition_number = @Partition,
|
||||
@data_compression = @CompressionType;
|
||||
END TRY
|
||||
BEGIN CATCH
|
||||
DECLARE @EstimationErrMsg NVARCHAR(MAX)
|
||||
SET @EstimationErrMsg = ERROR_MESSAGE()
|
||||
RAISERROR(N'-- ERROR while running sp_estimate_data_compression_savings: %s',0,1,@EstimationErrMsg);
|
||||
END CATCH
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
RAISERROR(N'-- Not a good candidate for compression. Skipping estimation check.',0,1);
|
||||
SET @ChecksSkipped = 1;
|
||||
END
|
||||
END
|
||||
ELSE IF @FeasibilityCheckOnly = 1
|
||||
SET @ChecksSkipped = 1
|
||||
ELSE
|
||||
BEGIN
|
||||
RAISERROR(N'-- Too big for TempDB. Skipping estimation check.',0,1);
|
||||
SET @ChecksSkipped = 1;
|
||||
END
|
||||
|
||||
-- Save to main results table
|
||||
INSERT INTO #ResultsAll
|
||||
SELECT
|
||||
[database_name] = @CurrDB
|
||||
, [schema_name] = @Schema
|
||||
, table_name = @Table
|
||||
, index_name = @IndexName
|
||||
, partition_number = @Partition
|
||||
, size_MB = @TotalSizeMB
|
||||
, in_row_percent = @InRowPercent
|
||||
, scan_percent = @ScanPercent
|
||||
, update_percent = @UpdatePercent
|
||||
, compression_type = @CompressionType
|
||||
, compression_ratio = 100 - (SUM(ISNULL(r.size_w_requested_compression_KB,0)) * 100.0 / NULLIF(SUM(ISNULL(r.size_w_current_compression_KB,0)),0))
|
||||
, compression_size_saving_KB = SUM(ISNULL(r.size_w_current_compression_KB,0)) - SUM(ISNULL(r.size_w_requested_compression_KB,0))
|
||||
, is_compression_feasible = @EstimationCheckRecommended
|
||||
, is_compression_recommended = CASE
|
||||
WHEN @FeasibilityCheckOnly = 1 OR @EstimationCheckRecommended = 0 THEN NULL
|
||||
WHEN
|
||||
100 - (SUM(ISNULL(r.size_w_requested_compression_KB,0)) * 100.0 / NULLIF(SUM(ISNULL(r.size_w_current_compression_KB,0)),0)) >= @CompressionRatioThreshold
|
||||
AND (SUM(ISNULL(r.size_w_current_compression_KB,0)) - SUM(ISNULL(r.size_w_requested_compression_KB,0))) / 1024.0 >= @CompressionSizeSavedMBThreshold
|
||||
THEN 1
|
||||
ELSE 0 END
|
||||
FROM
|
||||
@Results AS r
|
||||
OPTION (RECOMPILE);
|
||||
|
||||
DELETE @Results;
|
||||
|
||||
FETCH NEXT FROM TablesToCheck
|
||||
INTO @CurrDB, @Schema, @ObjectId, @Table, @IndexId, @IndexName, @Partition, @CompressionType, @TotalSizeMB, @InRowPercent, @ScanPercent, @UpdatePercent
|
||||
END
|
||||
|
||||
EndOfCursor:
|
||||
|
||||
CLOSE TablesToCheck
|
||||
DEALLOCATE TablesToCheck
|
||||
|
||||
IF @ChecksSkipped = 1
|
||||
BEGIN
|
||||
PRINT N'-- One or more tables were not checked. Please adjust threshold parameter values and make sure you have enough free disk space if you want to run those checks anyway.'
|
||||
END
|
||||
|
||||
-- Return results to client
|
||||
SELECT
|
||||
[database_name]
|
||||
,[schema_name]
|
||||
,[table_name]
|
||||
,full_table_name = QUOTENAME([schema_name]) + '.' + QUOTENAME([table_name])
|
||||
,index_name
|
||||
,partition_number = ISNULL(CONVERT(varchar(256),partition_number),'ALL')
|
||||
,size_MB
|
||||
,compressible_data = CONVERT(varchar(10), in_row_percent) + ' %'
|
||||
,scan_percent = CONVERT(varchar(10), scan_percent) + ' %'
|
||||
,update_percent = CONVERT(varchar(10), update_percent) + ' %'
|
||||
,compression_type
|
||||
,compression_ratio = ROUND(compression_ratio,3)
|
||||
,compression_size_saving_MB = compression_size_saving_KB / 1024.0
|
||||
,is_compression_candidate = CASE WHEN is_compression_feasible = 1 THEN 'Yes' ELSE 'No' END
|
||||
,is_compression_recommended = CASE
|
||||
WHEN is_compression_recommended IS NULL AND is_compression_feasible = 1 THEN
|
||||
CASE
|
||||
WHEN in_row_percent < @MinimumCompressibleDataPercent THEN N'No'
|
||||
WHEN compression_type = 'PAGE' AND ISNULL(update_percent,0) <= @MaximumUpdatePctAsInfrequent THEN 'Yes'
|
||||
WHEN scan_percent >= @MinimumScanPctForPage AND update_percent <= @MaximumUpdatePctForPage THEN
|
||||
CASE WHEN compression_type = 'PAGE' THEN 'Yes' ELSE 'No' END
|
||||
WHEN update_percent <= @MaximumUpdatePctForRow THEN
|
||||
CASE WHEN compression_type = 'ROW' THEN 'Yes' ELSE 'No' END
|
||||
ELSE 'No'
|
||||
END + ' (best guess)'
|
||||
WHEN is_compression_recommended = 1 AND SavingsRating = 1 THEN 'Yes' ELSE 'No'
|
||||
END
|
||||
,remediation_command =
|
||||
CASE WHEN ISNULL(is_compression_recommended,0) = 0 OR SavingsRating <> 1 THEN N'-- ' ELSE N'' END
|
||||
+ N'USE ' + QUOTENAME([database_name]) + N'; ALTER ' + ISNULL(N'INDEX ' + QUOTENAME(index_name) + N' ON ', N'TABLE ') + QUOTENAME([schema_name]) + '.' + QUOTENAME([table_name])
|
||||
+ N' REBUILD PARTITION = ' + ISNULL(CONVERT(nvarchar(max),partition_number), N'ALL')
|
||||
+ N' WITH (DATA_COMPRESSION = ' + compression_type + @RebuildOptions + N');'
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
*, SavingsRating = ROW_NUMBER() OVER (
|
||||
PARTITION BY
|
||||
[database_name]
|
||||
, table_name
|
||||
, index_name
|
||||
, partition_number
|
||||
, is_compression_recommended
|
||||
ORDER BY
|
||||
compression_ratio + (CASE WHEN compression_type = 'ROW' THEN @MinimumRatioDifferenceForPage ELSE 0 END) DESC,
|
||||
compression_size_saving_KB + (CASE WHEN compression_type = 'ROW' THEN ISNULL(@MinimumSavingsMBDifferenceForPage,0) * 1024.0 ELSE 0 END) DESC
|
||||
)
|
||||
FROM #ResultsAll
|
||||
) AS r
|
||||
ORDER BY
|
||||
[database_name] ASC
|
||||
, compression_size_saving_KB DESC
|
||||
, compression_ratio DESC
|
||||
, size_MB DESC
|
||||
OPTION (RECOMPILE);
|
||||
|
||||
IF @@ROWCOUNT > 0 AND @FeasibilityCheckOnly = 0
|
||||
BEGIN
|
||||
-- Begin generating remediation script that takes into consideration all checks
|
||||
-- including ROW vs. PAGE considerations
|
||||
DECLARE @PrevDB SYSNAME;
|
||||
SET @PrevDB = N'';
|
||||
SET @CMD = NULL;
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
PRINT N'---------- Recommendation Script Begins Below -------------------------'
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
|
||||
DECLARE Rebuilds CURSOR
|
||||
LOCAL FORWARD_ONLY FAST_FORWARD
|
||||
FOR
|
||||
SELECT
|
||||
[database_name]
|
||||
, InsertCmd = N'INSERT INTO #INDEXTABLE VALUES ('
|
||||
+ ISNULL(QUOTENAME([index_name], N''''), N'NULL') + N', '
|
||||
+ QUOTENAME(QUOTENAME([schema_name]) + N'.' + QUOTENAME([table_name]), N'''') + N', '
|
||||
+ ISNULL(CONVERT(nvarchar(max), partition_number), N'NULL') + N', '
|
||||
+ QUOTENAME([compression_type], N'''') + N');'
|
||||
--, RemediationCmd = N'USE ' + QUOTENAME([database_name]) + N'; ALTER ' + ISNULL(N'INDEX ' + QUOTENAME(index_name) + N' ON ', N'TABLE ') + QUOTENAME([schema_name]) + '.' + QUOTENAME([table_name]) + N'
|
||||
--REBUILD PARTITION = ' + ISNULL(CONVERT(nvarchar,partition_number), N'ALL') + N' WITH (DATA_COMPRESSION = ' + compression_type + @RebuildOptions + N');'
|
||||
--, StatusMessage = QUOTENAME([database_name]) + N': ' + ISNULL(N'INDEX ' + QUOTENAME(index_name) + N' ON ', N'TABLE ') + QUOTENAME([schema_name]) + N'.' + QUOTENAME([table_name])
|
||||
-- + N' PARTITION = ' + ISNULL(CONVERT(nvarchar,partition_number), N'ALL') + N', DATA_COMPRESSION = ' + compression_type
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
[database_name]
|
||||
, [schema_name]
|
||||
, table_name
|
||||
, index_name
|
||||
, compression_size_saving_KB
|
||||
, compression_ratio
|
||||
, compression_type
|
||||
, partition_number
|
||||
, SavingsRating = ROW_NUMBER() OVER (
|
||||
PARTITION BY
|
||||
[database_name]
|
||||
, table_name
|
||||
, index_name
|
||||
, partition_number
|
||||
ORDER BY
|
||||
compression_ratio + (CASE WHEN compression_type = 'ROW' THEN @MinimumRatioDifferenceForPage ELSE 0 END) DESC,
|
||||
compression_size_saving_KB + (CASE WHEN compression_type = 'ROW' THEN ISNULL(@MinimumSavingsMBDifferenceForPage,0) * 1024.0 ELSE 0 END) DESC
|
||||
)
|
||||
FROM
|
||||
#ResultsAll
|
||||
WHERE
|
||||
is_compression_recommended = 1
|
||||
) AS q
|
||||
WHERE SavingsRating = 1
|
||||
ORDER BY
|
||||
[database_name] ASC
|
||||
, compression_size_saving_KB DESC
|
||||
, compression_ratio DESC
|
||||
|
||||
OPEN Rebuilds
|
||||
FETCH NEXT FROM Rebuilds INTO @CurrDB, @CMD
|
||||
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
IF @CurrDB <> @PrevDB
|
||||
BEGIN
|
||||
PRINT N'USE ' + QUOTENAME(@CurrDB) + N';
|
||||
DECLARE @Size INT, @DB SYSNAME;
|
||||
SELECT @Size = SUM(FILEPROPERTY([name], ''SpaceUsed'')) / 128.0 FROM sys.database_files WHERE type = 0;
|
||||
SET @DB = DB_NAME();
|
||||
|
||||
RAISERROR(N''Space used for data in "%s" BEFORE compression: %d MB'', 0, 1, @DB, @Size) WITH NOWAIT;
|
||||
GO
|
||||
SET NOCOUNT, QUOTED_IDENTIFIER, ARITHABORT, XACT_ABORT ON;
|
||||
IF OBJECT_ID(''tempdb..#INDEXTABLE'') IS NOT NULL DROP TABLE #INDEXTABLE;
|
||||
CREATE TABLE #INDEXTABLE (
|
||||
IndexName SYSNAME NULL,
|
||||
TableName NVARCHAR(4000) NOT NULL,
|
||||
PartitionNumber INT NULL,
|
||||
CompressionType SYSNAME NOT NULL
|
||||
)
|
||||
'
|
||||
SET @PrevDB = @CurrDB;
|
||||
END
|
||||
|
||||
PRINT @CMD;
|
||||
|
||||
FETCH NEXT FROM Rebuilds INTO @CurrDB, @CMD;
|
||||
|
||||
IF @@FETCH_STATUS <> 0 OR @CurrDB <> @PrevDB
|
||||
BEGIN
|
||||
PRINT N'GO
|
||||
USE ' + QUOTENAME(@PrevDB) + N';
|
||||
|
||||
DECLARE @WhatIf BIT = 0
|
||||
|
||||
SET NOCOUNT, QUOTED_IDENTIFIER, ARITHABORT, XACT_ABORT ON;
|
||||
DECLARE @DB SYSNAME;
|
||||
SET @DB = DB_NAME();
|
||||
DECLARE @time VARCHAR(25)
|
||||
DECLARE @IndexName SYSNAME, @TableName NVARCHAR(4000), @PartitionNumber INT, @CompressionType SYSNAME, @CMD NVARCHAR(MAX)'
|
||||
|
||||
PRINT N'DECLARE TablesToCheck CURSOR
|
||||
LOCAL FORWARD_ONLY FAST_FORWARD
|
||||
FOR
|
||||
SELECT IndexName, TableName, PartitionNumber, CompressionType,
|
||||
Cmd = N''USE '' + QUOTENAME(@DB) + N''; ALTER '' + ISNULL(N''INDEX '' + QUOTENAME(IndexName) + N'' ON '', N''TABLE '') + TableName
|
||||
+ N'' REBUILD PARTITION = '' + ISNULL(CONVERT(nvarchar,PartitionNumber), N''ALL'')
|
||||
+ N'' WITH (DATA_COMPRESSION = '' + CompressionType + N''' + @RebuildOptions + N');''
|
||||
FROM #INDEXTABLE
|
||||
|
||||
OPEN TablesToCheck
|
||||
|
||||
WHILE 1 = 1
|
||||
BEGIN
|
||||
FETCH NEXT FROM TablesToCheck INTO @IndexName, @TableName, @PartitionNumber, @CompressionType, @CMD
|
||||
|
||||
IF @@FETCH_STATUS <> 0
|
||||
BREAK;'
|
||||
|
||||
IF @AllowedRuntimeHourFrom IS NOT NULL AND @AllowedRuntimeHourTo IS NOT NULL
|
||||
PRINT N'
|
||||
IF DATEPART(hour, GETDATE()) NOT BETWEEN ' + CONVERT(nvarchar(MAX), @AllowedRuntimeHourFrom) + N' AND ' + CONVERT(nvarchar(MAX), @AllowedRuntimeHourTo) + N'
|
||||
BEGIN
|
||||
SET @time = CONVERT(VARCHAR(25), GETDATE(), 121);
|
||||
RAISERROR(N''%s - Reached outside allowed execution time.'', 0, 1, @time);
|
||||
BREAK;
|
||||
END'
|
||||
|
||||
IF @NotAllowedRuntimeHourFrom IS NOT NULL AND @NotAllowedRuntimeHourTo IS NOT NULL
|
||||
PRINT N'
|
||||
IF DATEPART(hour, GETDATE()) BETWEEN ' + CONVERT(nvarchar(MAX), @NotAllowedRuntimeHourFrom) + N' AND ' + CONVERT(nvarchar(MAX), @NotAllowedRuntimeHourTo) + N'
|
||||
BEGIN
|
||||
SET @time = CONVERT(VARCHAR(25), GETDATE(), 121);
|
||||
RAISERROR(N''%s - Reached outside allowed execution time.'', 0, 1, @time);
|
||||
BREAK;
|
||||
END'
|
||||
|
||||
IF @MaximumCPUPercentForRebuild IS NOT NULL
|
||||
PRINT N'
|
||||
DECLARE @AvgCPU FLOAT, @WaitForCPUStartTime DATETIME;
|
||||
|
||||
CpuUtilizationCheck:
|
||||
SELECT @AvgCPU = AVG( 100 - record.value(''(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]'', ''int'') )
|
||||
from (
|
||||
SELECT TOP (' + CONVERT(nvarchar(MAX), @SamplesToCheckAvgForCPUPercent) + N') [timestamp], convert(xml, record) as record
|
||||
FROM sys.dm_os_ring_buffers
|
||||
WHERE ring_buffer_type = N''RING_BUFFER_SCHEDULER_MONITOR''
|
||||
AND record like ''%<SystemHealth>%''
|
||||
ORDER BY [timestamp] DESC
|
||||
) as RingBufferInfo
|
||||
|
||||
IF @AvgCPU <= ' + CONVERT(nvarchar(MAX), @MaximumCPUPercentForRebuild) + N'
|
||||
BEGIN
|
||||
SET @WaitForCPUStartTime = NULL;
|
||||
END' + CASE WHEN @MaximumTimeToWaitForCPU IS NOT NULL THEN N'
|
||||
ELSE IF @WaitForCPUStartTime IS NULL
|
||||
BEGIN
|
||||
SET @WaitForCPUStartTime = GETDATE()
|
||||
GOTO CpuUtilizationCheck;
|
||||
END
|
||||
ELSE IF @WaitForCPUStartTime + ' + QUOTENAME(CONVERT(nvarchar(max), @MaximumTimeToWaitForCPU, 121), N'''') + N' > GETDATE()
|
||||
BEGIN
|
||||
SET @time = CONVERT(VARCHAR(25), GETDATE(), 121);
|
||||
RAISERROR(N''%s - CPU utilization is too high.'', 0, 1, @time);
|
||||
BREAK;
|
||||
END' ELSE N'' END + N'
|
||||
ELSE
|
||||
BEGIN
|
||||
WAITFOR DELAY ''00:00:00.5''
|
||||
GOTO CpuUtilizationCheck;
|
||||
END'
|
||||
|
||||
PRINT N'
|
||||
|
||||
-- Check if index has no compression
|
||||
IF EXISTS (
|
||||
SELECT NULL
|
||||
FROM sys.partitions AS p WITH (NOLOCK)
|
||||
INNER JOIN sys.indexes AS ix WITH (NOLOCK)
|
||||
ON ix.object_id = p.object_id
|
||||
AND ix.index_id = p.index_id
|
||||
WHERE ix.object_id = OBJECT_ID(@TableName)
|
||||
AND (ix.name = @IndexName OR (@IndexName IS NULL AND ix.index_id = 0))
|
||||
AND p.data_compression_desc <> @CompressionType
|
||||
AND (@PartitionNumber IS NULL OR p.partition_number = @PartitionNumber)
|
||||
)
|
||||
BEGIN
|
||||
SET @time = CONVERT(VARCHAR(25), GETDATE(), 121);
|
||||
RAISERROR (N''%s - [%s]: INDEX [%s] ON %s PARTITION = %s, DATA_COMPRESSION = %s'', 0, 1, @time, @DB, @IndexName, @TableName, @PartitionNumber, @CompressionType) WITH NOWAIT;
|
||||
PRINT @CMD;
|
||||
IF @WhatIf = 0 EXEC sp_executesql @CMD;
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
CLOSE TablesToCheck
|
||||
DEALLOCATE TablesToCheck
|
||||
|
||||
DROP TABLE #INDEXTABLE
|
||||
|
||||
GO'
|
||||
PRINT N'USE ' + QUOTENAME(@PrevDB) + N';
|
||||
DECLARE @Size INT, @DB SYSNAME;
|
||||
SET @DB = DB_NAME();
|
||||
SELECT @Size = SUM(FILEPROPERTY([name], ''SpaceUsed'')) / 128.0 FROM sys.database_files WHERE type = 0;
|
||||
|
||||
RAISERROR(N''Space used for data in "%s" AFTER compression: %d MB'', 0, 1, @DB, @Size) WITH NOWAIT;
|
||||
GO'
|
||||
END --IF @@FETCH_STATUS <> 0 OR @CurrDB <> @PrevDB
|
||||
END -- WHILE @@FETCH_STATUS = 0
|
||||
PRINT N'DECLARE @time VARCHAR(25) = CONVERT(varchar(25), GETDATE(), 121); RAISERROR(N''%s - Done'',0,1,@time) WITH NOWAIT;'
|
||||
|
||||
CLOSE Rebuilds
|
||||
DEALLOCATE Rebuilds
|
||||
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
PRINT N'----------- Recommendation Script Ends Here --------------------------'
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
END
|
||||
ELSE IF @FeasibilityCheckOnly = 1
|
||||
BEGIN
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
PRINT N'-------- Feasibility Check Only - No Script Generated -----------------'
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
PRINT N'----------- No Candidates for Compression Found -----------------------'
|
||||
PRINT N'-----------------------------------------------------------------------'
|
||||
END
|
||||
|
||||
PRINT N'GO'
|
||||
|
||||
Quit:
|
||||
11
amr not treated count.sql
Normal file
11
amr not treated count.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
EXEC [ActiveSystemServer].[amr].[MonitoringReport] 7
|
||||
|
||||
return
|
||||
|
||||
SELECT
|
||||
COUNT(1)
|
||||
,cast(AMR_ArizonaRep_extraction_TS as date) as dt
|
||||
FROM Arizona.dbo.APS_monitor_row a
|
||||
where AMR_ArizonaRep_extraction_TS is not null
|
||||
group by cast(AMR_ArizonaRep_extraction_TS as date)
|
||||
order by dt desc
|
||||
12
bag mi create publication sl2007.sql
Normal file
12
bag mi create publication sl2007.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
EXEC sp_adddistributor @distributor = @@ServerName;
|
||||
EXEC sp_adddistributiondb @database = N'distribution';
|
||||
|
||||
USE [master]
|
||||
EXEC sp_adddistpublisher
|
||||
@publisher = @@ServerName,
|
||||
@distribution_db = N'distribution',
|
||||
@security_mode = 0,
|
||||
@login = N'sql-repl_agent',
|
||||
@password = N'teY^C~7i:x:Ed&pXX|7!',
|
||||
@working_directory = N'\\stbagspezlisteprdsql.file.core.windows.net\fs-bagspezlisteprd-replication',
|
||||
@storage_connection_string = N'DefaultEndpointsProtocol=https;AccountName=stbagspezlisteprdsql;AccountKey=iM5rSBBgr11oLv654yrotzLGwkEcJyBoZpbbTwiSbDfloyWiYOXERMVyDhc0A/3uwriXdKhSpvOZ+AStjh4ZFg==;EndpointSuffix=core.windows.net';
|
||||
34
bag mi drop publication.sql
Normal file
34
bag mi drop publication.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
SELECT TOP (1000)*
|
||||
FROM [msdb].[dbo].MSdistpublishers
|
||||
|
||||
SELECT TOP (1000)*
|
||||
FROM [msdb].[dbo].MSdistributiondbs
|
||||
|
||||
SELECT TOP (1000)*
|
||||
FROM [msdb].[dbo].MSdistributor
|
||||
|
||||
return
|
||||
|
||||
|
||||
-- Disable publishing and distribution.
|
||||
DECLARE @distributionDB AS sysname;
|
||||
DECLARE @publisher AS sysname;
|
||||
DECLARE @publicationDB as sysname;
|
||||
SET @distributionDB = N'distribution';
|
||||
SET @publisher = @@SERVERNAME;
|
||||
SET @publicationDB = N'sl2007';
|
||||
|
||||
-- Disable the publication database.
|
||||
USE SL2007
|
||||
EXEC sp_removedbreplication @publicationDB;
|
||||
|
||||
-- Remove the registration of the local Publisher at the Distributor.
|
||||
USE master
|
||||
EXEC sp_dropdistpublisher @publisher;
|
||||
|
||||
-- Delete the distribution database.
|
||||
EXEC sp_dropdistributiondb @distributionDB;
|
||||
|
||||
-- Remove the local server as a Distributor.
|
||||
EXEC sp_dropdistributor;
|
||||
GO
|
||||
114
central index correction.sql
Normal file
114
central index correction.sql
Normal file
@@ -0,0 +1,114 @@
|
||||
|
||||
declare @cvCurrentOrganizationalUnit int,
|
||||
@CV_OUT_value varchar(8000),
|
||||
@ou_code varchar(10),
|
||||
@ServerName varchar(20),
|
||||
@restartdate datetime,
|
||||
@errno int,
|
||||
@errmsg varchar(255),
|
||||
@LnkSrv varchar(15),
|
||||
@cmd varchar(8000),
|
||||
@Entity varchar(4);
|
||||
|
||||
exec arizona.dbo.sp_bmc_Bmc_Applic_Default
|
||||
@in_job_type = 3,
|
||||
@in_param_int_1 = null,
|
||||
@in_param_int_2 = null,
|
||||
@in_param_varchar_1 = 'cvCurrentOrganizationalUnit',
|
||||
@out_default_value = @CV_out_value output,
|
||||
@out_param_int_1 = null;
|
||||
select @cvCurrentOrganizationalUnit = convert(int,@CV_out_value);
|
||||
|
||||
select @ou_code = ou.ou_code
|
||||
from arizona.dbo.Organizational_unit ou (nolock)
|
||||
where ou.Organizational_unit_ID = @cvCurrentOrganizationalUnit;
|
||||
|
||||
SELECT @Entity = [Customer] FROM [master].[cfg].[Identity];
|
||||
SET @ServerName = @Entity+isnull(@ou_code,'')+'APS';
|
||||
|
||||
select @RestartDate = MIN(login_time)
|
||||
from sys.dm_exec_sessions;
|
||||
|
||||
SET @LnkSrv = 'ARIZONACASH';
|
||||
|
||||
SET @cmd = '
|
||||
|
||||
IF OBJECT_ID(''tempdb..#tmp'')IS NOT NULL BEGIN
|
||||
DROP TABLE #tmp;
|
||||
END
|
||||
|
||||
SELECT TOP 50000
|
||||
'''+@ServerName+''' as [SI_ServerName]
|
||||
,[Stats_index_ID]
|
||||
,[SI_schemaname]
|
||||
,[SI_databasename]
|
||||
,[SI_tablename]
|
||||
,[SI_indexname]
|
||||
,[SI_indextype]
|
||||
,[SI_user_seeks]
|
||||
,[SI_user_scans]
|
||||
,[SI_user_lookups]
|
||||
,[SI_user_updates]
|
||||
,[SI_last_user_seek]
|
||||
,[SI_last_user_scan]
|
||||
,[SI_last_user_lookup]
|
||||
,[SI_last_user_update]
|
||||
,[SI_updatedate]
|
||||
,[SI_restartdate]
|
||||
,NULL as [SI_deletedate]
|
||||
into #tmp
|
||||
FROM [HCITools].[dbo].[Stats_index] si WITH (NOLOCK)
|
||||
WHERE SI_updatedate < CAST('''+CONVERT(nvarchar(30),@RestartDate,126)+''' as datetime);
|
||||
|
||||
select ''delete from ARIZONACASH.HCITools.dbo.All_Stats_Index where [SI_ServerName] = ''''''+s.[SI_ServerName]+'''''' and [Stats_index_ID]=''+cast(s.[Stats_index_ID] as varchar(50))+'';'' as queryForCentral
|
||||
from ARIZONACASH.HCITools.dbo.All_Stats_Index t
|
||||
inner join #tmp s on s.[SI_ServerName] = t.[SI_ServerName] and s.[Stats_index_ID] = t.[Stats_index_ID];
|
||||
|
||||
|
||||
--INSERT INTO '+@LnkSrv+'.HCITools.dbo.All_Stats_Index(
|
||||
-- [SI_ServerName]
|
||||
-- ,[Stats_index_ID]
|
||||
-- ,[SI_schemaname]
|
||||
-- ,[SI_databasename]
|
||||
-- ,[SI_tablename]
|
||||
-- ,[SI_indexname]
|
||||
-- ,[SI_indextype]
|
||||
-- ,[SI_user_seeks]
|
||||
-- ,[SI_user_scans]
|
||||
-- ,[SI_user_lookups]
|
||||
-- ,[SI_user_updates]
|
||||
-- ,[SI_last_user_seek]
|
||||
-- ,[SI_last_user_scan]
|
||||
-- ,[SI_last_user_lookup]
|
||||
-- ,[SI_last_user_update]
|
||||
-- ,[SI_updatedate]
|
||||
-- ,[SI_restartdate]
|
||||
-- ,[SI_deletedate]
|
||||
--)
|
||||
--select [SI_ServerName]
|
||||
-- ,[Stats_index_ID]
|
||||
-- ,[SI_schemaname]
|
||||
-- ,[SI_databasename]
|
||||
-- ,[SI_tablename]
|
||||
-- ,[SI_indexname]
|
||||
-- ,[SI_indextype]
|
||||
-- ,[SI_user_seeks]
|
||||
-- ,[SI_user_scans]
|
||||
-- ,[SI_user_lookups]
|
||||
-- ,[SI_user_updates]
|
||||
-- ,[SI_last_user_seek]
|
||||
-- ,[SI_last_user_scan]
|
||||
-- ,[SI_last_user_lookup]
|
||||
-- ,[SI_last_user_update]
|
||||
-- ,[SI_updatedate]
|
||||
-- ,[SI_restartdate]
|
||||
-- ,[SI_deletedate]
|
||||
--from #tmp;
|
||||
--print ''inserted in central'';
|
||||
--print @@rowcount;
|
||||
|
||||
DROP TABLE #tmp;
|
||||
|
||||
'
|
||||
print @cmd
|
||||
EXEC (@cmd)
|
||||
38
check gaia publication.sql
Normal file
38
check gaia publication.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
SELECT
|
||||
mda.publication [PUB Name],
|
||||
(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],
|
||||
CONVERT(VARCHAR(25),mdh.[time]) [LastSynchronized],
|
||||
und.UndelivCmdsInDistDB [UndistCom],
|
||||
mdh.comments [Comments],
|
||||
mdh.xact_seqno [SEQ_NO]
|
||||
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'
|
||||
and mda.publication = 'publ_Ceres_Arizona_Gaia_Tran'
|
||||
order by mdh.[time]
|
||||
16
check restore history.sql
Normal file
16
check restore history.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
WITH LastRestores AS
|
||||
(
|
||||
SELECT
|
||||
DatabaseName = [d].[name] ,
|
||||
[d].[create_date] ,
|
||||
[d].[compatibility_level] ,
|
||||
[d].[collation_name] ,
|
||||
r.*,
|
||||
RowNum = ROW_NUMBER() OVER (PARTITION BY d.Name ORDER BY r.[restore_date] DESC)
|
||||
FROM master.sys.databases d
|
||||
LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = d.Name
|
||||
)
|
||||
SELECT *
|
||||
FROM [LastRestores]
|
||||
WHERE [RowNum] = 1
|
||||
order by restore_date desc
|
||||
115
craft xml replication monitor.sql
Normal file
115
craft xml replication monitor.sql
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Connect to hcimon and run this query.
|
||||
Then, insert the publisher and the distributors entry in this fragment
|
||||
|
||||
https://www.sqlservercentral.com/forums/topic/how-to-import-replication-monitor-my-publishers-into-ssms-across-versions
|
||||
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PublisherGroups>
|
||||
<ViewSetting Value="group" />
|
||||
<Group Name="My Publishers">
|
||||
|
||||
<!-- copy Publisher nodes here -->
|
||||
|
||||
</Group>
|
||||
|
||||
<!-- copy Distributor nodes here -->
|
||||
|
||||
</PublisherGroups>
|
||||
|
||||
and save it in the local folder
|
||||
C:\Users\ua208700\AppData\Roaming\Microsoft\Microsoft SQL Server\200\Tools\SQL Monitor\rmsetting.xml
|
||||
|
||||
*/
|
||||
USE [ControlCenter]
|
||||
|
||||
DECLARE @tpl VARCHAR(MAX)='
|
||||
<Publisher>
|
||||
<name>@srv@\@inst@</name>
|
||||
<Distributor>@srv@\@inst@</Distributor>
|
||||
<Interval>5</Interval>
|
||||
<AutoRefresh>True</AutoRefresh>
|
||||
<AutoConnect>False</AutoConnect>
|
||||
<IsOraclePublisher>False</IsOraclePublisher>
|
||||
<LastSelectedAgentType>Snapshot Agent</LastSelectedAgentType>
|
||||
<LastSelectedFilterType>0</LastSelectedFilterType>
|
||||
<LastSelectedPubType>0</LastSelectedPubType>
|
||||
<LastSelectedTab>0</LastSelectedTab>
|
||||
<GridSettings />
|
||||
</Publisher>
|
||||
'
|
||||
DECLARE @tplDis VARCHAR(MAX)='
|
||||
<DistributorsSetting Name="@srv@\@inst@">
|
||||
<Interval>5</Interval>
|
||||
<AutoRefresh>True</AutoRefresh>
|
||||
<AutoConnect>False</AutoConnect>
|
||||
<LastSelectedAgentType>Snapshot Agent</LastSelectedAgentType>
|
||||
<LastSelectedFilterType>0</LastSelectedFilterType>
|
||||
<LastSelectedPubType>-1</LastSelectedPubType>
|
||||
<LastSelectedTab>0</LastSelectedTab>
|
||||
<GridSettings />
|
||||
</DistributorsSetting>
|
||||
'
|
||||
/****** Script for SelectTopNRows command from SSMS ******/
|
||||
SELECT [SE_designation]
|
||||
,[SE_OU_code]
|
||||
,[SE_DNS]
|
||||
,[SE_instance_name]
|
||||
,e.[EN_designation]
|
||||
,REPLACE(
|
||||
REPLACE(@tpl,'@inst@', s.[SE_instance_name])
|
||||
,'@srv@'
|
||||
,CASE
|
||||
--WHEN [e].[EN_designation]='amavita' THEN 'SAMNB'
|
||||
--WHEN [e].[EN_designation]='Coop-Vitality' THEN 'SCVNB'
|
||||
--WHEN [e].[EN_designation]='Sun Store' THEN 'SSUNB'
|
||||
WHEN [e].[EN_designation]='amavita' THEN 'SWAMA'
|
||||
WHEN [e].[EN_designation]='Coop-Vitality' THEN 'SWCVI'
|
||||
WHEN [e].[EN_designation]='Sun Store' THEN 'SWSUN'
|
||||
ELSE ''
|
||||
END +RIGHT(CAST([s].[SE_OU_code] AS CHAR(3)),3)+'VM01'
|
||||
)AS xmlPub
|
||||
,REPLACE(
|
||||
REPLACE(@tplDis,'@inst@', s.[SE_instance_name])
|
||||
,'@srv@'
|
||||
,CASE
|
||||
--WHEN [e].[EN_designation]='amavita' THEN 'SAMNB'
|
||||
--WHEN [e].[EN_designation]='Coop-Vitality' THEN 'SCVNB'
|
||||
--WHEN [e].[EN_designation]='Sun Store' THEN 'SSUNB'
|
||||
WHEN [e].[EN_designation]='amavita' THEN 'SWAMA'
|
||||
WHEN [e].[EN_designation]='Coop-Vitality' THEN 'SWCVI'
|
||||
WHEN [e].[EN_designation]='Sun Store' THEN 'SWSUN'
|
||||
ELSE ''
|
||||
END +RIGHT(CAST([s].[SE_OU_code] AS CHAR(3)),3)+'VM01'
|
||||
)AS xmlDist
|
||||
,CASE
|
||||
--WHEN [e].[EN_designation]='amavita' THEN 'SAMNB'
|
||||
--WHEN [e].[EN_designation]='Coop-Vitality' THEN 'SCVNB'
|
||||
--WHEN [e].[EN_designation]='Sun Store' THEN 'SSUNB'
|
||||
WHEN [e].[EN_designation]='amavita' THEN 'SWAMA'
|
||||
WHEN [e].[EN_designation]='Coop-Vitality' THEN 'SWCVI'
|
||||
WHEN [e].[EN_designation]='Sun Store' THEN 'SWSUN'
|
||||
ELSE ''
|
||||
END +RIGHT(CAST([s].[SE_OU_code] AS CHAR(3)),3)+'VM01'
|
||||
+'\'+[s].[SE_instance_name]
|
||||
AS ou
|
||||
FROM [dbo].[Server] s
|
||||
JOIN dbo.[Entity] e ON [e].[EN_id] = [s].[SE_entity]
|
||||
WHERE [e].[EN_designation] IN ('Coop-Vitality', 'amavita', 'sun store')
|
||||
--and left(SE_DNS, 9) in (
|
||||
--'AMA272APS',
|
||||
--'AMA269APS',
|
||||
--'AMA299APS',
|
||||
--'AMA301APS',
|
||||
--'AMA302APS',
|
||||
--'AMA303APS',
|
||||
--'AMA305APS',
|
||||
--'AMA622APS',
|
||||
--'AMA624APS',
|
||||
--'AMA625APS',
|
||||
--'SUN841APS',
|
||||
--'SUN851APS',
|
||||
--'SUN871APS',
|
||||
--'SUN891APS')
|
||||
ORDER BY SE_DNS
|
||||
12
deadlock analysis from extended event ring buffer.sql
Normal file
12
deadlock analysis from extended event ring buffer.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
SELECT
|
||||
CAST(event_data.value('(event/data/value)[1]', 'nvarchar(max)') AS XML) AS DeadlockGraphXml
|
||||
FROM (
|
||||
SELECT CAST(target_data AS XML) AS TargetData
|
||||
FROM sys.dm_xe_sessions AS s
|
||||
JOIN sys.dm_xe_session_targets AS t
|
||||
ON s.address = t.event_session_address
|
||||
WHERE s.name = 'deadLocks'
|
||||
AND t.target_name = 'ring_buffer'
|
||||
) AS SessionData
|
||||
CROSS APPLY TargetData.nodes('//RingBufferTarget/event') AS EventNodes(event_data)
|
||||
WHERE event_data.value('@name', 'nvarchar(100)') IN ('xml_deadlock_report', 'database_xml_deadlock_report');
|
||||
10
deadlock extended events to ring buffer.sql
Normal file
10
deadlock extended events to ring buffer.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE EVENT SESSION [deadLocks] ON SERVER
|
||||
ADD EVENT sqlserver.database_xml_deadlock_report(
|
||||
ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.compile_plan_guid,sqlserver.database_name,sqlserver.nt_username,sqlserver.sql_text)),
|
||||
ADD EVENT sqlserver.xml_deadlock_report(
|
||||
ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.compile_plan_guid,sqlserver.database_name,sqlserver.nt_username,sqlserver.sql_text))
|
||||
ADD TARGET package0.ring_buffer
|
||||
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)
|
||||
GO
|
||||
|
||||
ALTER EVENT SESSION [deadLocks] ON SERVER STATE = START;
|
||||
7
drop publication.sql
Normal file
7
drop publication.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
USE < **Publication database name** >
|
||||
GO
|
||||
EXEC sp_droppublication @publication = N'<Publication name>'
|
||||
|
||||
USE master
|
||||
GO
|
||||
exec sp_replicationdboption @dbname = N'<Publication database name>', @optname = N'publish', @value = N'false'
|
||||
1
dump.sql
Normal file
1
dump.sql
Normal file
@@ -0,0 +1 @@
|
||||
EXEC [HCITools].dbo.[bkp_Dump] @in_Recovery_Model = 'FULL,SIMPLE';
|
||||
BIN
hcitools.dbo.Replication_Check.sql
Normal file
BIN
hcitools.dbo.Replication_Check.sql
Normal file
Binary file not shown.
145
idx1.sql
Normal file
145
idx1.sql
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
Server: samnb705db01.amavita.ch
|
||||
Format: GCM
|
||||
Business: TPPHAR
|
||||
type: VALI
|
||||
Version: 23.1.21006.00066
|
||||
|
||||
06.06.2024, TSC
|
||||
*/
|
||||
;WITH ColInfo
|
||||
AS (SELECT TblName = o.name,
|
||||
SchemaTbl = s.name + '.' + o.name,
|
||||
IndexName = i.name,
|
||||
IsPrimaryKey = [i].[is_primary_key],
|
||||
IsUniqueConstraint = [i].[is_unique_constraint],
|
||||
IsUnique = [i].[is_unique],
|
||||
ColName = c.name,
|
||||
IsComputedCol = [c].[is_computed],
|
||||
IsIncludedCol = [ic].[is_included_column],
|
||||
[ic].[key_ordinal],
|
||||
FilterDefinition = [i].[filter_definition],
|
||||
i.[index_id],
|
||||
crlf = CHAR(13) + CHAR(10),
|
||||
crlfgo = ';' + CHAR(13) + CHAR(10) + 'GO' + CHAR(13) + CHAR(10),
|
||||
[o].[object_id]
|
||||
FROM sys.objects o
|
||||
INNER JOIN sys.schemas s
|
||||
ON o.schema_id = s.schema_id
|
||||
INNER JOIN sys.columns c
|
||||
ON o.object_id = c.object_id
|
||||
INNER JOIN sys.indexes i
|
||||
ON c.object_id = i.object_id
|
||||
INNER JOIN sys.index_columns ic
|
||||
ON i.index_id = ic.index_id
|
||||
AND o.object_id = ic.object_id
|
||||
AND c.column_id = ic.column_id
|
||||
WHERE s.name = 'dbo'
|
||||
AND o.name = 'account_chart'
|
||||
--AND i.filter_definition IS NOT NULL
|
||||
)
|
||||
SELECT DISTINCT [x].[TblName],
|
||||
[x].[IndexName],
|
||||
[x].[index_id],
|
||||
[x].[IsPrimaryKey],
|
||||
[x].[IsUniqueConstraint],
|
||||
[x].[IsUnique],
|
||||
--,size.IndexSizeKB
|
||||
[c].[IndexColumns],
|
||||
[ci].[IncludedColumns],
|
||||
[cc].[ComputedColumns],
|
||||
[x].[FilterDefinition],
|
||||
[sz].[IndexSizeMB],
|
||||
[us].[Reads],
|
||||
[us].[Writes],
|
||||
DropCreateSQL = [x].[crlf] + '-- ' + x.IndexName + [x].[crlf] +
|
||||
--check drop
|
||||
'IF INDEXPROPERTY(OBJECT_ID(''' + [x].[SchemaTbl] + '''), ''' + x.IndexName
|
||||
+ ''' , ''IndexID'' ) IS NOT NULL BEGIN;' + [x].[crlf]
|
||||
+ CASE
|
||||
WHEN [x].[IsPrimaryKey] = 1 THEN NULL
|
||||
WHEN [x].[IsUniqueConstraint] = 1 THEN
|
||||
--drop statement
|
||||
' ALTER TABLE ' + [x].[SchemaTbl] + ' DROP CONSTRAINT ' + x.IndexName + ';'
|
||||
+ [x].[crlf] + 'END' + [x].[crlfgo]
|
||||
--check create
|
||||
+ 'IF INDEXPROPERTY(OBJECT_ID(''' + [x].[SchemaTbl] + '''), ''' + x.IndexName
|
||||
+ ''' , ''IndexID'' ) IS NULL BEGIN;' + [x].[crlf] +
|
||||
--create statement
|
||||
+' ALTER TABLE '
|
||||
+ [x].[SchemaTbl] + ' ADD CONSTRAINT ' + x.IndexName + ' UNIQUE ('
|
||||
+ [c].[IndexColumns] + ');' + [x].[crlf] + 'END' + [x].[crlfgo]
|
||||
ELSE
|
||||
--drop statement
|
||||
' DROP INDEX ' + [x].[SchemaTbl] + '.' + x.IndexName + ';' + [x].[crlf]
|
||||
+ 'END' + [x].[crlfgo]
|
||||
--check create
|
||||
+ 'IF INDEXPROPERTY(OBJECT_ID(''' + [x].[SchemaTbl] + '''), ''' + x.IndexName
|
||||
+ ''' , ''IndexID'' ) IS NULL BEGIN;' + [x].[crlf] +
|
||||
--create statement
|
||||
+' CREATE '
|
||||
+ CASE
|
||||
WHEN [x].[IsUnique] = 1 THEN 'UNIQUE '
|
||||
ELSE '' END + 'INDEX ' + x.IndexName + ' ON ' + [x].[SchemaTbl] + '('
|
||||
+ [c].[IndexColumns] + ')'
|
||||
+ ISNULL(' INCLUDE(' + [ci].[IncludedColumns] + ')', '')
|
||||
+ ISNULL(' WHERE ' + [x].[FilterDefinition], '') + ';' + [x].[crlf] + 'END'
|
||||
+ [x].[crlfgo] END
|
||||
FROM ColInfo x
|
||||
OUTER APPLY ( SELECT IndexColumns = STUFF([sq].[strXML], 1, 2, '')
|
||||
FROM ( SELECT ', ' + ISNULL([x2].[ColName], '')
|
||||
FROM ColInfo x2
|
||||
WHERE x.TblName = [x2].[TblName]
|
||||
AND x.IndexName = [x2].[IndexName]
|
||||
AND [x2].[IsIncludedCol] = 0
|
||||
ORDER BY x2.key_ordinal
|
||||
FOR XML PATH('')) sq(strXML) ) c
|
||||
OUTER APPLY ( SELECT IncludedColumns = STUFF([sq].[strXML], 1, 2, '')
|
||||
FROM ( SELECT ', ' + ISNULL([x2].[ColName], '')
|
||||
FROM ColInfo x2
|
||||
WHERE x.TblName = [x2].[TblName]
|
||||
AND x.IndexName = [x2].[IndexName]
|
||||
AND [x2].[IsIncludedCol] = 1
|
||||
ORDER BY x2.key_ordinal
|
||||
FOR XML PATH('')) sq(strXML) ) ci
|
||||
OUTER APPLY ( SELECT ComputedColumns = STUFF([sq].[strXML], 1, 2, '')
|
||||
FROM ( SELECT ', ' + ISNULL([x2].[ColName], '')
|
||||
FROM ColInfo x2
|
||||
WHERE x.TblName = [x2].[TblName]
|
||||
AND x.IndexName = [x2].[IndexName]
|
||||
AND [x2].[IsComputedCol] = 1
|
||||
ORDER BY x2.key_ordinal
|
||||
FOR XML PATH('')) sq(strXML) ) cc
|
||||
OUTER APPLY ( SELECT tblName = o.name,
|
||||
o.type,
|
||||
i.name AS [IndexName],
|
||||
i.index_id,
|
||||
[s].[user_seeks] + [s].[user_scans] + [s].[user_lookups] AS [Reads],
|
||||
[s].[user_updates] AS [Writes],
|
||||
i.type_desc AS [IndexType],
|
||||
[i].[fill_factor] AS [FillFactor],
|
||||
[i].[has_filter],
|
||||
[i].[filter_definition],
|
||||
[s].[last_user_scan],
|
||||
[s].[last_user_lookup],
|
||||
[s].[last_user_seek]
|
||||
FROM sys.dm_db_index_usage_stats AS s WITH (NOLOCK)
|
||||
INNER JOIN sys.indexes AS i WITH (NOLOCK)
|
||||
ON s.object_id = i.object_id
|
||||
INNER JOIN sys.objects o WITH (NOLOCK)
|
||||
ON s.object_id = o.object_id
|
||||
WHERE o.type = 'U' -- user table
|
||||
AND i.index_id = s.index_id
|
||||
AND [s].[database_id] = DB_ID()
|
||||
AND o.name = x.TblName
|
||||
AND i.name = x.IndexName) us
|
||||
OUTER APPLY ( SELECT [i].[name] AS IndexName,
|
||||
SUM([s].[used_page_count]) * 8 / 1024 AS IndexSizeMB
|
||||
FROM sys.dm_db_partition_stats AS s
|
||||
JOIN sys.indexes AS i
|
||||
ON s.[object_id] = i.[object_id]
|
||||
AND s.index_id = i.index_id
|
||||
WHERE s.[object_id] = x.[object_id] --OBJECT_ID('dbo.document_line')
|
||||
AND [i].[name] = x.IndexName
|
||||
GROUP BY [i].[name]) sz
|
||||
ORDER BY [x].[index_id];
|
||||
67
last sp_configure call.sql
Normal file
67
last sp_configure call.sql
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
SET NOCOUNT ON;
|
||||
|
||||
-- Create the temp table
|
||||
IF EXISTS (SELECT * FROM msdb.sys.objects WHERE NAME = 'SQLskillsDBCCPage')
|
||||
DROP TABLE msdb.dbo.SQLskillsDBCCPage;
|
||||
|
||||
CREATE TABLE msdb.dbo.SQLskillsDBCCPage (
|
||||
[ParentObject] VARCHAR (100),
|
||||
[Object] VARCHAR (100),
|
||||
[Field] VARCHAR (100),
|
||||
[VALUE] VARCHAR (100));
|
||||
|
||||
DECLARE @hours INT;
|
||||
DECLARE @minutes INT;
|
||||
DECLARE @seconds INT;
|
||||
DECLARE @milliseconds BIGINT;
|
||||
DECLARE @LastUpdateTime DATETIME;
|
||||
DECLARE @upddate INT;
|
||||
DECLARE @updtime BIGINT;
|
||||
DECLARE @dbccPageString VARCHAR (200);
|
||||
|
||||
--Build the dynamic SQL
|
||||
|
||||
SELECT @dbccPageString = 'DBCC PAGE (master, 1, 10, 3) WITH TABLERESULTS, NO_INFOMSGS';
|
||||
|
||||
--Empty out the temp table and insert into it again
|
||||
--
|
||||
INSERT INTO msdb.dbo.SQLskillsDBCCPage EXEC (@dbccPageString);
|
||||
|
||||
SELECT @updtime = [VALUE] FROM msdb.dbo.SQLskillsDBCCPage
|
||||
WHERE [Field] = 'cfgupdtime';
|
||||
SELECT @upddate = [VALUE] FROM msdb.dbo.SQLskillsDBCCPage
|
||||
WHERE [Field] = 'cfgupddate';
|
||||
|
||||
--Convert updtime to seconds
|
||||
SELECT @milliseconds = CONVERT (INT, CONVERT (FLOAT, @updtime) * (3 + 1.0/3))
|
||||
SELECT @updtime = @milliseconds / 1000;
|
||||
|
||||
--Pull out hours, minutes, seconds, milliseconds
|
||||
SELECT @hours = @updtime / 3600;
|
||||
|
||||
SELECT @minutes = (@updtime % 3600) / 60;
|
||||
|
||||
SELECT @seconds = @updtime - (@hours * 3600) - (@minutes * 60);
|
||||
|
||||
--Calculate number of milliseconds
|
||||
SELECT @milliseconds = @milliseconds -
|
||||
@seconds * 1000 -
|
||||
@minutes * 60 * 1000 -
|
||||
@hours * 3600 * 1000;
|
||||
|
||||
--No messy conversion code required for the date as SQL Server can do it for us
|
||||
SELECT @LastUpdateTime = DATEADD (DAY, @upddate, '1900-01-01');
|
||||
|
||||
--And add in the hours, minutes, seconds, and milliseconds
|
||||
--There are nicer functions to do this but they don't work in 2005/2008
|
||||
SELECT @LastUpdateTime = DATEADD (HOUR, @hours, @LastUpdateTime);
|
||||
SELECT @LastUpdateTime = DATEADD (MINUTE, @minutes, @LastUpdateTime);
|
||||
SELECT @LastUpdateTime = DATEADD (SECOND, @seconds, @LastUpdateTime);
|
||||
SELECT @LastUpdateTime = DATEADD (MILLISECOND, @milliseconds, @LastUpdateTime);
|
||||
|
||||
SELECT @LastUpdateTime AS 'sp_configure options last updated';
|
||||
|
||||
--Clean up
|
||||
--
|
||||
DROP TABLE msdb.dbo.SQLskillsDBCCPage;
|
||||
7
list pos.sql
Normal file
7
list pos.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
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]
|
||||
;
|
||||
59
new max memory setting.sql
Normal file
59
new max memory setting.sql
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 23.06.2021 RTC TFS 65413 Optimize RAM configuration */
|
||||
EXEC sys.sp_configure N'show advanced options', N'1' RECONFIGURE WITH OVERRIDE
|
||||
GO
|
||||
EXEC sys.sp_configure N'min server memory (MB)', N'1024'
|
||||
GO
|
||||
|
||||
DECLARE @maxMem INT;
|
||||
DECLARE @totSysMemKb INT;
|
||||
DECLARE @NumOfCores INT;
|
||||
DECLARE @NumOfProcessors INT;
|
||||
DECLARE @NumOfSQLThreads INT;
|
||||
DECLARE @isX64 BIT = 1;
|
||||
DECLARE @ThreadStackSize INT;
|
||||
DECLARE @osReserved INT;
|
||||
DECLARE @newMaxMem INT;
|
||||
DECLARE @appReserved INT = 4*1024*1024; --memory reserved for other apps on the server in Kb
|
||||
|
||||
SELECT @totSysMemKb = [total_physical_memory_kb]
|
||||
FROM [sys].[dm_os_sys_memory];
|
||||
|
||||
SELECT @NumOfCores = [cpu_count], @NumOfProcessors = [cpu_count] / [hyperthread_ratio]
|
||||
FROM [sys].[dm_os_sys_info];
|
||||
|
||||
SELECT @isX64 = CHARINDEX('64-bit',CAST(SERVERPROPERTY('Edition') AS VARCHAR(MAX)));
|
||||
|
||||
SELECT @ThreadStackSize = CASE WHEN @isX64=1 THEN 4096 ELSE 2048 END;
|
||||
|
||||
SELECT @NumOfSQLThreads = 256 + (@NumOfProcessors - 4) * 8 * (CASE WHEN @NumOfProcessors >4 THEN @NumOfProcessors ELSE 0 END);
|
||||
|
||||
|
||||
select @NumOfCores = 1, @NumOfProcessors = 8
|
||||
|
||||
SELECT @osReserved = CASE WHEN @totSysMemKb < (20*1024*1024) THEN @totSysMemKb * 0.2 ELSE @totSysMemKb * 0.125 END;
|
||||
|
||||
PRINT'
|
||||
@totSysMemKb: '+COALESCE(CAST(@totSysMemKb AS VARCHAR(MAX)),'null')+'
|
||||
@NumOfCores: '+COALESCE(CAST(@NumOfCores AS VARCHAR(MAX)),'null')+'
|
||||
@NumOfProcessors: '+COALESCE(CAST(@NumOfProcessors AS VARCHAR(MAX)),'null')+'
|
||||
@NumOfSQLThreads: '+COALESCE(CAST(@NumOfSQLThreads AS VARCHAR(MAX)),'null')+'
|
||||
@isX64: '+COALESCE(CAST(@isX64 AS VARCHAR(MAX)),'null')+'
|
||||
@ThreadStackSize: '+COALESCE(CAST(@ThreadStackSize AS VARCHAR(MAX)),'null')+'
|
||||
@osReserved: '+COALESCE(CAST(@osReserved AS VARCHAR(MAX)),'null')+'
|
||||
@appReserved: '+COALESCE(CAST(@appReserved AS VARCHAR(MAX)),'null')+'
|
||||
';
|
||||
SELECT @newMaxMem = @totSysMemKb - (@NumOfSQLThreads * @ThreadStackSize) - ((1* 1024 * 1024) * CEILING(@NumOfCores/4)) - @osReserved - @appReserved;
|
||||
|
||||
SELECT @MaxMem = @newMaxMem / 1024
|
||||
|
||||
select @maxmem
|
||||
|
||||
EXEC sys.sp_configure N'max server memory (MB)', @maxMem
|
||||
RECONFIGURE WITH OVERRIDE
|
||||
EXEC sys.sp_configure N'show advanced options', N'0' RECONFIGURE WITH OVERRIDE
|
||||
|
||||
UPDATE HCITools.dbo.HCI_PARAMS
|
||||
SET HCIP_value = @MaxMem
|
||||
WHERE HCIP_key = 'MAXSRVMEM'
|
||||
|
||||
GO
|
||||
17
orphaned users.sql
Normal file
17
orphaned users.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
use artikel_superset
|
||||
|
||||
|
||||
select p.name,p.sid, 'DROP USER ['+p.name+']' as q
|
||||
from sys.database_principals p
|
||||
where p.type in ('G','S','U')
|
||||
and p.sid not in (select sid from sys.server_principals)
|
||||
and p.name not in (
|
||||
'dbo',
|
||||
'guest',
|
||||
'INFORMATION_SCHEMA',
|
||||
'sys',
|
||||
'MS_DataCollectorInternalUser'
|
||||
) ;
|
||||
|
||||
return
|
||||
|
||||
120
paul randal wait analysis.sql
Normal file
120
paul randal wait analysis.sql
Normal file
@@ -0,0 +1,120 @@
|
||||
-- Last updated October 1, 2021
|
||||
WITH [Waits] AS
|
||||
(SELECT
|
||||
[wait_type],
|
||||
[wait_time_ms] / 1000.0 AS [WaitS],
|
||||
([wait_time_ms] - [signal_wait_time_ms]) / 1000.0 AS [ResourceS],
|
||||
[signal_wait_time_ms] / 1000.0 AS [SignalS],
|
||||
[waiting_tasks_count] AS [WaitCount],
|
||||
100.0 * [wait_time_ms] / SUM ([wait_time_ms]) OVER() AS [Percentage],
|
||||
ROW_NUMBER() OVER(ORDER BY [wait_time_ms] DESC) AS [RowNum]
|
||||
FROM sys.dm_os_wait_stats
|
||||
WHERE [wait_type] NOT IN (
|
||||
-- These wait types are almost 100% never a problem and so they are
|
||||
-- filtered out to avoid them skewing the results. Click on the URL
|
||||
-- for more information.
|
||||
N'BROKER_EVENTHANDLER', -- https://www.sqlskills.com/help/waits/BROKER_EVENTHANDLER
|
||||
N'BROKER_RECEIVE_WAITFOR', -- https://www.sqlskills.com/help/waits/BROKER_RECEIVE_WAITFOR
|
||||
N'BROKER_TASK_STOP', -- https://www.sqlskills.com/help/waits/BROKER_TASK_STOP
|
||||
N'BROKER_TO_FLUSH', -- https://www.sqlskills.com/help/waits/BROKER_TO_FLUSH
|
||||
N'BROKER_TRANSMITTER', -- https://www.sqlskills.com/help/waits/BROKER_TRANSMITTER
|
||||
N'CHECKPOINT_QUEUE', -- https://www.sqlskills.com/help/waits/CHECKPOINT_QUEUE
|
||||
N'CHKPT', -- https://www.sqlskills.com/help/waits/CHKPT
|
||||
N'CLR_AUTO_EVENT', -- https://www.sqlskills.com/help/waits/CLR_AUTO_EVENT
|
||||
N'CLR_MANUAL_EVENT', -- https://www.sqlskills.com/help/waits/CLR_MANUAL_EVENT
|
||||
N'CLR_SEMAPHORE', -- https://www.sqlskills.com/help/waits/CLR_SEMAPHORE
|
||||
|
||||
-- Maybe comment this out if you have parallelism issues
|
||||
N'CXCONSUMER', -- https://www.sqlskills.com/help/waits/CXCONSUMER
|
||||
|
||||
-- Maybe comment these four out if you have mirroring issues
|
||||
N'DBMIRROR_DBM_EVENT', -- https://www.sqlskills.com/help/waits/DBMIRROR_DBM_EVENT
|
||||
N'DBMIRROR_EVENTS_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_EVENTS_QUEUE
|
||||
N'DBMIRROR_WORKER_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_WORKER_QUEUE
|
||||
N'DBMIRRORING_CMD', -- https://www.sqlskills.com/help/waits/DBMIRRORING_CMD
|
||||
N'DIRTY_PAGE_POLL', -- https://www.sqlskills.com/help/waits/DIRTY_PAGE_POLL
|
||||
N'DISPATCHER_QUEUE_SEMAPHORE', -- https://www.sqlskills.com/help/waits/DISPATCHER_QUEUE_SEMAPHORE
|
||||
N'EXECSYNC', -- https://www.sqlskills.com/help/waits/EXECSYNC
|
||||
N'FSAGENT', -- https://www.sqlskills.com/help/waits/FSAGENT
|
||||
N'FT_IFTS_SCHEDULER_IDLE_WAIT', -- https://www.sqlskills.com/help/waits/FT_IFTS_SCHEDULER_IDLE_WAIT
|
||||
N'FT_IFTSHC_MUTEX', -- https://www.sqlskills.com/help/waits/FT_IFTSHC_MUTEX
|
||||
|
||||
-- Maybe comment these six out if you have AG issues
|
||||
N'HADR_CLUSAPI_CALL', -- https://www.sqlskills.com/help/waits/HADR_CLUSAPI_CALL
|
||||
N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', -- https://www.sqlskills.com/help/waits/HADR_FILESTREAM_IOMGR_IOCOMPLETION
|
||||
N'HADR_LOGCAPTURE_WAIT', -- https://www.sqlskills.com/help/waits/HADR_LOGCAPTURE_WAIT
|
||||
N'HADR_NOTIFICATION_DEQUEUE', -- https://www.sqlskills.com/help/waits/HADR_NOTIFICATION_DEQUEUE
|
||||
N'HADR_TIMER_TASK', -- https://www.sqlskills.com/help/waits/HADR_TIMER_TASK
|
||||
N'HADR_WORK_QUEUE', -- https://www.sqlskills.com/help/waits/HADR_WORK_QUEUE
|
||||
|
||||
N'KSOURCE_WAKEUP', -- https://www.sqlskills.com/help/waits/KSOURCE_WAKEUP
|
||||
N'LAZYWRITER_SLEEP', -- https://www.sqlskills.com/help/waits/LAZYWRITER_SLEEP
|
||||
N'LOGMGR_QUEUE', -- https://www.sqlskills.com/help/waits/LOGMGR_QUEUE
|
||||
N'MEMORY_ALLOCATION_EXT', -- https://www.sqlskills.com/help/waits/MEMORY_ALLOCATION_EXT
|
||||
N'ONDEMAND_TASK_QUEUE', -- https://www.sqlskills.com/help/waits/ONDEMAND_TASK_QUEUE
|
||||
N'PARALLEL_REDO_DRAIN_WORKER', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_DRAIN_WORKER
|
||||
N'PARALLEL_REDO_LOG_CACHE', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_LOG_CACHE
|
||||
N'PARALLEL_REDO_TRAN_LIST', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_TRAN_LIST
|
||||
N'PARALLEL_REDO_WORKER_SYNC', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_SYNC
|
||||
N'PARALLEL_REDO_WORKER_WAIT_WORK', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_WAIT_WORK
|
||||
N'PREEMPTIVE_OS_FLUSHFILEBUFFERS', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_OS_FLUSHFILEBUFFERS
|
||||
N'PREEMPTIVE_XE_GETTARGETSTATE', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_XE_GETTARGETSTATE
|
||||
N'PVS_PREALLOCATE', -- https://www.sqlskills.com/help/waits/PVS_PREALLOCATE
|
||||
N'PWAIT_ALL_COMPONENTS_INITIALIZED', -- https://www.sqlskills.com/help/waits/PWAIT_ALL_COMPONENTS_INITIALIZED
|
||||
N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', -- https://www.sqlskills.com/help/waits/PWAIT_DIRECTLOGCONSUMER_GETNEXT
|
||||
N'PWAIT_EXTENSIBILITY_CLEANUP_TASK', -- https://www.sqlskills.com/help/waits/PWAIT_EXTENSIBILITY_CLEANUP_TASK
|
||||
N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', -- https://www.sqlskills.com/help/waits/QDS_PERSIST_TASK_MAIN_LOOP_SLEEP
|
||||
N'QDS_ASYNC_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_ASYNC_QUEUE
|
||||
N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',
|
||||
-- https://www.sqlskills.com/help/waits/QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP
|
||||
N'QDS_SHUTDOWN_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_SHUTDOWN_QUEUE
|
||||
N'REDO_THREAD_PENDING_WORK', -- https://www.sqlskills.com/help/waits/REDO_THREAD_PENDING_WORK
|
||||
N'REQUEST_FOR_DEADLOCK_SEARCH', -- https://www.sqlskills.com/help/waits/REQUEST_FOR_DEADLOCK_SEARCH
|
||||
N'RESOURCE_QUEUE', -- https://www.sqlskills.com/help/waits/RESOURCE_QUEUE
|
||||
N'SERVER_IDLE_CHECK', -- https://www.sqlskills.com/help/waits/SERVER_IDLE_CHECK
|
||||
N'SLEEP_BPOOL_FLUSH', -- https://www.sqlskills.com/help/waits/SLEEP_BPOOL_FLUSH
|
||||
N'SLEEP_DBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DBSTARTUP
|
||||
N'SLEEP_DCOMSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DCOMSTARTUP
|
||||
N'SLEEP_MASTERDBREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERDBREADY
|
||||
N'SLEEP_MASTERMDREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERMDREADY
|
||||
N'SLEEP_MASTERUPGRADED', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERUPGRADED
|
||||
N'SLEEP_MSDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_MSDBSTARTUP
|
||||
N'SLEEP_SYSTEMTASK', -- https://www.sqlskills.com/help/waits/SLEEP_SYSTEMTASK
|
||||
N'SLEEP_TASK', -- https://www.sqlskills.com/help/waits/SLEEP_TASK
|
||||
N'SLEEP_TEMPDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_TEMPDBSTARTUP
|
||||
N'SNI_HTTP_ACCEPT', -- https://www.sqlskills.com/help/waits/SNI_HTTP_ACCEPT
|
||||
N'SOS_WORK_DISPATCHER', -- https://www.sqlskills.com/help/waits/SOS_WORK_DISPATCHER
|
||||
N'SP_SERVER_DIAGNOSTICS_SLEEP', -- https://www.sqlskills.com/help/waits/SP_SERVER_DIAGNOSTICS_SLEEP
|
||||
N'SQLTRACE_BUFFER_FLUSH', -- https://www.sqlskills.com/help/waits/SQLTRACE_BUFFER_FLUSH
|
||||
N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', -- https://www.sqlskills.com/help/waits/SQLTRACE_INCREMENTAL_FLUSH_SLEEP
|
||||
N'SQLTRACE_WAIT_ENTRIES', -- https://www.sqlskills.com/help/waits/SQLTRACE_WAIT_ENTRIES
|
||||
N'VDI_CLIENT_OTHER', -- https://www.sqlskills.com/help/waits/VDI_CLIENT_OTHER
|
||||
N'WAIT_FOR_RESULTS', -- https://www.sqlskills.com/help/waits/WAIT_FOR_RESULTS
|
||||
N'WAITFOR', -- https://www.sqlskills.com/help/waits/WAITFOR
|
||||
N'WAITFOR_TASKSHUTDOWN', -- https://www.sqlskills.com/help/waits/WAITFOR_TASKSHUTDOWN
|
||||
N'WAIT_XTP_RECOVERY', -- https://www.sqlskills.com/help/waits/WAIT_XTP_RECOVERY
|
||||
N'WAIT_XTP_HOST_WAIT', -- https://www.sqlskills.com/help/waits/WAIT_XTP_HOST_WAIT
|
||||
N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', -- https://www.sqlskills.com/help/waits/WAIT_XTP_OFFLINE_CKPT_NEW_LOG
|
||||
N'WAIT_XTP_CKPT_CLOSE', -- https://www.sqlskills.com/help/waits/WAIT_XTP_CKPT_CLOSE
|
||||
N'XE_DISPATCHER_JOIN', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_JOIN
|
||||
N'XE_DISPATCHER_WAIT', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_WAIT
|
||||
N'XE_TIMER_EVENT' -- https://www.sqlskills.com/help/waits/XE_TIMER_EVENT
|
||||
)
|
||||
AND [waiting_tasks_count] > 0
|
||||
)
|
||||
SELECT
|
||||
MAX ([W1].[wait_type]) AS [WaitType],
|
||||
CAST (MAX ([W1].[WaitS]) AS DECIMAL (16,2)) AS [Wait_S],
|
||||
CAST (MAX ([W1].[ResourceS]) AS DECIMAL (16,2)) AS [Resource_S],
|
||||
CAST (MAX ([W1].[SignalS]) AS DECIMAL (16,2)) AS [Signal_S],
|
||||
MAX ([W1].[WaitCount]) AS [WaitCount],
|
||||
CAST (MAX ([W1].[Percentage]) AS DECIMAL (5,2)) AS [Percentage],
|
||||
CAST ((MAX ([W1].[WaitS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgWait_S],
|
||||
CAST ((MAX ([W1].[ResourceS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgRes_S],
|
||||
CAST ((MAX ([W1].[SignalS]) / MAX ([W1].[WaitCount])) AS DECIMAL (16,4)) AS [AvgSig_S],
|
||||
CAST ('https://www.sqlskills.com/help/waits/' + MAX ([W1].[wait_type]) as XML) AS [Help/Info URL]
|
||||
FROM [Waits] AS [W1]
|
||||
INNER JOIN [Waits] AS [W2] ON [W2].[RowNum] <= [W1].[RowNum]
|
||||
GROUP BY [W1].[RowNum]
|
||||
HAVING SUM ([W2].[Percentage]) - MAX( [W1].[Percentage] ) < 95; -- percentage threshold
|
||||
GO
|
||||
86
repl.sql
Normal file
86
repl.sql
Normal 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
|
||||
26
search object owner before deletion of user.sql
Normal file
26
search object owner before deletion of user.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
use UeberpruefungBAG2024
|
||||
|
||||
-- Replace 'username' with the actual username
|
||||
DECLARE @username NVARCHAR(128) = 'E-MEDIAT\uapvi';
|
||||
|
||||
-- Find schemas owned by the user
|
||||
SELECT schema_name(schema_id) AS SchemaName
|
||||
FROM sys.schemas
|
||||
WHERE principal_id = USER_ID(@username);
|
||||
|
||||
-- Find objects owned by the user
|
||||
SELECT
|
||||
o.name AS ObjectName,
|
||||
o.type_desc AS ObjectType,
|
||||
s.name AS SchemaName
|
||||
FROM
|
||||
sys.objects o
|
||||
JOIN
|
||||
sys.schemas s ON o.schema_id = s.schema_id
|
||||
WHERE
|
||||
o.principal_id = USER_ID(@username);
|
||||
GO
|
||||
|
||||
return
|
||||
|
||||
ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [dbo];
|
||||
988
sl2007 cloud publication scripted.sql
Normal file
988
sl2007 cloud publication scripted.sql
Normal file
@@ -0,0 +1,988 @@
|
||||
-- Enabling the replication database
|
||||
use master
|
||||
exec sp_replicationdboption @dbname = N'SL2007', @optname = N'publish', @value = N'true'
|
||||
GO
|
||||
|
||||
-- Adding the snapshot publication
|
||||
use [SL2007]
|
||||
exec sp_addpublication @publication = N'sl2007', @description = N'Snapshot publication of database ''SL2007'' from Publisher ''sqlmi-bagspezlisteprd-sqlinstance.75ff9425ac13.database.windows.net''.', @sync_method = N'native', @retention = 0, @allow_push = N'true', @allow_pull = N'true', @allow_anonymous = N'false', @enabled_for_internet = N'false', @snapshot_in_defaultfolder = N'true', @compress_snapshot = N'false', @ftp_port = 21, @ftp_login = N'anonymous', @allow_subscription_copy = N'false', @add_to_active_directory = N'false', @repl_freq = N'snapshot', @status = N'active', @independent_agent = N'true', @immediate_sync = N'false', @allow_sync_tran = N'false', @autogen_sync_procs = N'false', @allow_queued_tran = N'false', @allow_dts = N'false', @replicate_ddl = 1
|
||||
GO
|
||||
|
||||
|
||||
exec sp_addpublication_snapshot @publication = N'sl2007', @frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 1, @frequency_recurrence_factor = 0, @frequency_subday = 1, @frequency_subday_interval = 1, @active_start_time_of_day = 213000, @active_end_time_of_day = 235959, @active_start_date = 0, @active_end_date = 0, @job_login = null, @job_password = null, @publisher_security_mode = 0, @publisher_login = N'sql-repl_agent', @publisher_password = null
|
||||
exec sp_grant_publication_access @publication = N'sl2007', @login = N'sa'
|
||||
GO
|
||||
exec sp_grant_publication_access @publication = N'sl2007', @login = N'sql-repl_agent'
|
||||
GO
|
||||
exec sp_grant_publication_access @publication = N'sl2007', @login = N'Sec-SQL-RL_DBAOps'
|
||||
GO
|
||||
exec sp_grant_publication_access @publication = N'sl2007', @login = N'distributor_admin'
|
||||
GO
|
||||
exec sp_grant_publication_access @publication = N'sl2007', @login = N'superuser'
|
||||
GO
|
||||
|
||||
-- Adding the snapshot articles
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'ATCDESCR', @source_owner = N'dbo', @source_object = N'ATCDESCR', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'ATCDESCR', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ATCDESCR', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'ATCDESCR', @view_name = N'syncobj_0x3442354642373135', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'COM_CHAIN', @source_owner = N'dbo', @source_object = N'COM_CHAIN', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'COM_CHAIN', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'Gamme', @source_owner = N'dbo', @source_object = N'Gamme', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'Gamme', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'GENERICBASEDATA_FROM_ARTIKEL_SUPERSET', @source_owner = N'dbo', @source_object = N'GENERICBASEDATA_FROM_ARTIKEL_SUPERSET', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'GENERICBASEDATA_FROM_ARTIKEL_SUPERSET', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'GENERICBASEDATA_FROM_ARTIKEL_SUPERSET_eme7w006', @source_owner = N'dbo', @source_object = N'GENERICBASEDATA_FROM_ARTIKEL_SUPERSET_eme7w006', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'GENERICBASEDATA_FROM_ARTIKEL_SUPERSET_eme7w006', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'IMSData', @source_owner = N'dbo', @source_object = N'IMSData', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'IMSData', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'IMSData_Add', @source_owner = N'dbo', @source_object = N'IMSData_Add', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'IMSData_Add', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'IMSData_Archiv', @source_owner = N'dbo', @source_object = N'IMSData_Archiv', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'IMSData_Archiv', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'IMSData_ExcelImport', @source_owner = N'dbo', @source_object = N'IMSData_ExcelImport', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'IMSData_ExcelImport', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'ITDESCR', @source_owner = N'dbo', @source_object = N'ITDESCR', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'ITDESCR', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'CDIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'ITCOMMENT_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'ITCOMMENT_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'ITCOMMENT_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'UeberpruefungseinheitCode', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITDESCR', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'ITDESCR', @view_name = N'syncobj_0x3533433046324531', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'ITLIMIT', @source_owner = N'dbo', @source_object = N'ITLIMIT', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'ITLIMIT', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'CDITLIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'CDIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'ITLIMIT', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'ITLIMIT', @view_name = N'syncobj_0x3144383039433430', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'LIMITATION', @source_owner = N'dbo', @source_object = N'LIMITATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'LIMITATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'LimitationChangeType_FK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'CDLIMIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'LIMITTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'LIMITNIVEAU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'LIMITVALUE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LIMITATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'LIMITATION', @view_name = N'syncobj_0x4243323946304234', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'LIMITATION_HISTORY', @source_owner = N'dbo', @source_object = N'LIMITATION_HISTORY', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'LIMITATION_HISTORY', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'LimitationChangeType', @source_owner = N'dbo', @source_object = N'LimitationChangeType', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'LimitationChangeType', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'LimitationChangeType_PK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'Code', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'Sort', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'Descr_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'Descr_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'DbStatus', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'DbInsDatim', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'DbInsUser', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'DbUpdDatim', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'DbUpdUser', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'LimitationChangeType', @column = N'Time_Stamp', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'LimitationChangeType', @view_name = N'syncobj_0x3835443739354632', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'LOASPEZ', @source_owner = N'dbo', @source_object = N'LOASPEZ', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'LOASPEZ', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'NATION', @source_owner = N'dbo', @source_object = N'NATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'NATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'NATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'NATION', @view_name = N'syncobj_0x4642424439353143', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'ORG_GEN_UMSATZ', @source_owner = N'dbo', @source_object = N'ORG_GEN_UMSATZ', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'ORG_GEN_UMSATZ', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'OrgGenManualGrenzwert', @source_owner = N'dbo', @source_object = N'OrgGenManualGrenzwert', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'OrgGenManualGrenzwert', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'ORIGINAL_FREIKAUF', @source_owner = N'dbo', @source_object = N'ORIGINAL_FREIKAUF', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'ORIGINAL_FREIKAUF', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'OriginalGenericMapping', @source_owner = N'dbo', @source_object = N'OriginalGenericMapping', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'OriginalGenericMapping', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACK', @source_owner = N'dbo', @source_object = N'PACK', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PACK', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'VertriebsanteilGruppeId', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'PACKNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_DE_OLD', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_FR_OLD', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_IT_OLD', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'Descr_DE_Full', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'Descr_FR_Full', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'SWISSMEDIC_CAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'BAGDOSSIERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'GTIN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'SIZEPACK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'PREV_GTINCODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'SWISSMEDICNR8_PARALLELIMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACK', @view_name = N'syncobj_0x3443354346353932', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACK_IGNORE', @source_owner = N'dbo', @source_object = N'PACK_IGNORE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PACK_IGNORE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'SWISSMEDIC_CAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'BAGDOSSIERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_IGNORE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACK_IGNORE', @view_name = N'syncobj_0x3444333441454230', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACK_LIMPTS', @source_owner = N'dbo', @source_object = N'PACK_LIMPTS', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PACK_LIMPTS', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'PACK_LIMPTSNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'LIMPOINTS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'LIMPACKS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_LIMPTS', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACK_LIMPTS', @view_name = N'syncobj_0x3141343444364633', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACK_MUTATION', @source_owner = N'dbo', @source_object = N'PACK_MUTATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PACK_MUTATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'PACKNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'SWISSMEDIC_CAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'BAGDOSSIERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_MUTATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACK_MUTATION', @view_name = N'syncobj_0x3437444637373230', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACK_NEW', @source_owner = N'dbo', @source_object = N'PACK_NEW', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PACK_NEW', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'SWISSMEDIC_CAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACK_NEW', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACK_NEW', @view_name = N'syncobj_0x3338453542303934', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACKPARTNER', @source_owner = N'dbo', @source_object = N'PACKPARTNER', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PACKPARTNER', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'PACKPARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'PARTNERTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACKPARTNER', @view_name = N'syncobj_0x3136344137444339', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @source_owner = N'dbo', @source_object = N'PACKPARTNER_IGNORE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PACKPARTNER_IGNORE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'PACKPARTNERIGNORENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACKPARTNER_IGNORE', @view_name = N'syncobj_0x4632313944344433', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @source_owner = N'dbo', @source_object = N'PACKPARTNER_MUTATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PACKPARTNER_MUTATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'PACKPARTNERMUTATIONNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'PARTNERTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACKPARTNER_MUTATION', @view_name = N'syncobj_0x3238453635323145', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PACKPRICE', @source_owner = N'dbo', @source_object = N'PACKPRICE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PACKPRICE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'PRICENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'CDPRICETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'PRICE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DIVISION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DIVPRICEINCVAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DIVISIONDESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'CDPRICECHANGETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PACKPRICE', @column = N'PRICEMODEL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PACKPRICE', @view_name = N'syncobj_0x3936343139303733', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PARTNER', @source_owner = N'dbo', @source_object = N'PARTNER', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PARTNER', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'PARTNERNRALT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'PARTNERNO_EMEDIAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'PT_NUMBER_ODB', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'NAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'ADDNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'STREET', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'PLZ', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'PLACE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'KANTON', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'EAN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'VATNR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'EMAIL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'INTERNET', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'CONTACT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'PHONE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'FAXNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PARTNER', @view_name = N'syncobj_0x3235443632334231', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PARTNER_IGNORE', @source_owner = N'dbo', @source_object = N'PARTNER_IGNORE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PARTNER_IGNORE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'PARTNERNO_EMEDIAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'COMPANYNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'ADDNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_IGNORE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PARTNER_IGNORE', @view_name = N'syncobj_0x4233433038344634', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PARTNER_MUTATION', @source_owner = N'dbo', @source_object = N'PARTNER_MUTATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PARTNER_MUTATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'PARTNERNO_EMEDIAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'COMPANYNAME_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'ADDNAME_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'COMPANYNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'ADDNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PARTNER_MUTATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PARTNER_MUTATION', @view_name = N'syncobj_0x3331334232364439', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PIMPORT', @source_owner = N'dbo', @source_object = N'PIMPORT', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PIMPORT', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PreiseNeu', @source_owner = N'dbo', @source_object = N'PreiseNeu', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PreiseNeu', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPARATION', @source_owner = N'dbo', @source_object = N'PREPARATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPARATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'PREPARNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'NAME_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'NAME_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'NAME_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'NAME_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'NAME_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'NAME_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'COMMENT_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'COMMENT_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'COMMENT_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'PREPNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'PREPNAMENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'PREPNAMENO_BOOK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'LOASPEZ', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'COM_FlagAPV', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'REVIEW_AFTER_PATENT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'PRICE_CUT_AFTER_MONTHS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION', @column = N'BWS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPARATION', @view_name = N'syncobj_0x4238383646453533', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @source_owner = N'dbo', @source_object = N'PREPARATION_IGNORE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PREPARATION_IGNORE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'NAME_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'NAME_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'NAME_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'NAME_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'NAME_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'NAME_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'COMMENT_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'COMMENT_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'COMMENT_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @column = N'FLAGGGSL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPARATION_IGNORE', @view_name = N'syncobj_0x4331343344383234', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @source_owner = N'dbo', @source_object = N'PREPARATION_MUTATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PREPARATION_MUTATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'PREPARNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'NAME_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'NAME_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'NAME_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @column = N'FLAGGGSL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPARATION_MUTATION', @view_name = N'syncobj_0x4343383131364338', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPARATION_NAME', @source_owner = N'dbo', @source_object = N'PREPARATION_NAME', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PREPARATION_NAME', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPARATION_NAME_BOOK', @source_owner = N'dbo', @source_object = N'PREPARATION_NAME_BOOK', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PREPARATION_NAME_BOOK', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPARATION_NEW', @source_owner = N'dbo', @source_object = N'PREPARATION_NEW', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PREPARATION_NEW', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'NAME_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'NAME_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'NAME_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATION_NEW', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPARATION_NEW', @view_name = N'syncobj_0x4546434130373545', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPARATIONTASK', @source_owner = N'dbo', @source_object = N'PREPARATIONTASK', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPARATIONTASK', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'PREPARATIONTASKNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'COMPLETED', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DUE_DATE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DUE_USERID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DUE_GROUPNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPARATIONTASK', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPARATIONTASK', @view_name = N'syncobj_0x3143333446383042', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PrepGenGroup', @source_owner = N'dbo', @source_object = N'PrepGenGroup', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PrepGenGroup', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPIT', @source_owner = N'dbo', @source_object = N'PREPIT', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPIT', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'PREPITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'CDIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPIT', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPIT', @view_name = N'syncobj_0x3343433138443844', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPPACKLIMIT', @source_owner = N'dbo', @source_object = N'PREPPACKLIMIT', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPPACKLIMIT', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'PREPLIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'PM_LIST_INDICATIONS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPPACKLIMIT', @view_name = N'syncobj_0x3133464233424135', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @source_owner = N'dbo', @source_object = N'PREPPACKLIMIT_GGML', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPPACKLIMIT_GGML', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'PREPLIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPPACKLIMIT_GGML', @view_name = N'syncobj_0x3446433146464146', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPPACKSTATUS', @source_owner = N'dbo', @source_object = N'PREPPACKSTATUS', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPPACKSTATUS', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'PREPPACKSTATUSNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DATEINTEGRAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'CDSTATUSTYPESL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'FLAGAPD', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPPACKSTATUS', @view_name = N'syncobj_0x3941344242303246', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @source_owner = N'dbo', @source_object = N'PREPPACKSTATUS_GGML', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPPACKSTATUS_GGML', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'PREPPACKSTATUSNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DATEINTEGRAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'CDSTATUSTYPEGGML', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'FLAGAPD', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPPACKSTATUS_GGML', @view_name = N'syncobj_0x3337323730353843', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PREPSUB', @source_owner = N'dbo', @source_object = N'PREPSUB', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPSUB', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'PREPSUBNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'CH_NUMBER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'CDWHK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'QUANTITY', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'QUANTITY_UNIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PREPSUB', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PREPSUB', @view_name = N'syncobj_0x3035433130303231', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PRICECHANGETYPE', @source_owner = N'dbo', @source_object = N'PRICECHANGETYPE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PRICECHANGETYPE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'CDPRICECHANGETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICECHANGETYPE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PRICECHANGETYPE', @view_name = N'syncobj_0x4144383742434437', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PRICETYPE', @source_owner = N'dbo', @source_object = N'PRICETYPE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PRICETYPE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'CDPRICETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PRICETYPE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PRICETYPE', @view_name = N'syncobj_0x4634393535334545', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PUBLICATION', @source_owner = N'dbo', @source_object = N'PUBLICATION', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PUBLICATION', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'PUBLICATIONNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'CDPUBLICATIONSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'BagBulletinFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'BagBulletinTextFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'ITCodesFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'GenericsFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'GenericListDiffSBFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'GeburtsGebrechenMedikamentListFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'PreparationsFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'PublicationsToExcelFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'DeletedPackagesFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'HistoryFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'GeburtsGebrechenSpezListFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION', @column = N'BagBulletinExcelName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PUBLICATION', @view_name = N'syncobj_0x3237434132454245', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @source_owner = N'dbo', @source_object = N'PUBLICATION_STATUS', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PUBLICATION_STATUS', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'CDPUBLICATIONSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'PUBLICATION_STATUS', @view_name = N'syncobj_0x3639393646363832', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'PublicationRun', @source_owner = N'dbo', @source_object = N'PublicationRun', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PublicationRun', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'RECIDKORR', @source_owner = N'dbo', @source_object = N'RECIDKORR', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'RECIDKORR', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'SL_AUFNSTRCH', @source_owner = N'dbo', @source_object = N'SL_AUFNSTRCH', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'SL_AUFNSTRCH', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @source_owner = N'dbo', @source_object = N'STATUSTYPE_GGML', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'STATUSTYPE_GGML', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'CDSTATUSTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'STATUSTYPE_GGML', @view_name = N'syncobj_0x3642453637313930', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'STATUSTYPE_SL', @source_owner = N'dbo', @source_object = N'STATUSTYPE_SL', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'STATUSTYPE_SL', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'CDSTATUSTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'STATUSTYPE_SL', @column = N'ACTIVE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'STATUSTYPE_SL', @view_name = N'syncobj_0x4530354230463542', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'SUBSTANCE', @source_owner = N'dbo', @source_object = N'SUBSTANCE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'SUBSTANCE', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'CH_NUMBER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'DESCR_LA_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'SUBSTANCE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'SUBSTANCE', @view_name = N'syncobj_0x4536344132384239', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'TEMP_BIG_APV', @source_owner = N'dbo', @source_object = N'TEMP_BIG_APV', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'TEMP_BIG_APV', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'temp_Modal_Formstaerke', @source_owner = N'dbo', @source_object = N'temp_Modal_Formstaerke', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'temp_Modal_Formstaerke', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'TempAPV20131101', @source_owner = N'dbo', @source_object = N'TempAPV20131101', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'TempAPV20131101', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'TempImport', @source_owner = N'dbo', @source_object = N'TempImport', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'TempImport', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'TempUmsatz3J', @source_owner = N'dbo', @source_object = N'TempUmsatz3J', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'TempUmsatz3J', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'TempUmsatzGamme', @source_owner = N'dbo', @source_object = N'TempUmsatzGamme', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'TempUmsatzGamme', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'test_repl', @source_owner = N'dbo', @source_object = N'test_repl', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'test_repl', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'TMP_ArtikelVerknuepfungen', @source_owner = N'dbo', @source_object = N'TMP_ArtikelVerknuepfungen', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'TMP_ArtikelVerknuepfungen', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'TMP_VertriebsanteilGruppe', @source_owner = N'dbo', @source_object = N'TMP_VertriebsanteilGruppe', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'TMP_VertriebsanteilGruppe', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'Ueberpruefungseinheit', @source_owner = N'dbo', @source_object = N'Ueberpruefungseinheit', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'Ueberpruefungseinheit', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'VARIA', @source_owner = N'dbo', @source_object = N'VARIA', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'VARIA', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'true', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
|
||||
-- Adding the article's partition column(s)
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'PHARMAGRUPPENCODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'IT_CODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'SIZEPACK_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'SIZEPACK_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'SIZEPACK_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'PRICE_WITH_MWST_2.5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'PRICE_WITH_MWST_2.6', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'PRICE_WITH_MWST_26_Correct', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'LIMITATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'TableNr', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'Sort', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
exec sp_articlecolumn @publication = N'sl2007', @article = N'VARIA', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
|
||||
-- Adding the article synchronization object
|
||||
exec sp_articleview @publication = N'sl2007', @article = N'VARIA', @view_name = N'syncobj_0x4531363137364133', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'VERLIST', @source_owner = N'dbo', @source_object = N'VERLIST', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'VERLIST', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
use [SL2007]
|
||||
exec sp_addarticle @publication = N'sl2007', @article = N'VertriebsanteilGruppe', @source_owner = N'dbo', @source_object = N'VertriebsanteilGruppe', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'VertriebsanteilGruppe', @destination_owner = N'dbo', @status = 24, @vertical_partition = N'false', @ins_cmd = N'SQL', @del_cmd = N'SQL', @upd_cmd = N'SQL'
|
||||
GO
|
||||
|
||||
-- Adding the snapshot subscriptions
|
||||
use [SL2007]
|
||||
exec sp_addsubscription @publication = N'sl2007', @subscriber = N'SWMDATASQLPRD01', @destination_db = N'SL2007', @subscription_type = N'Pull', @sync_type = N'automatic', @article = N'all', @update_mode = N'read only', @subscriber_type = 0
|
||||
GO
|
||||
|
||||
21
tde encryption status.sql
Normal file
21
tde encryption status.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
USE master
|
||||
|
||||
SELECT
|
||||
DB_NAME(k.database_id) AS DatabaseName
|
||||
,k.encryption_state
|
||||
,encryption_state_desc =
|
||||
CASE k.encryption_state
|
||||
WHEN '0' THEN 'No database encryption key present, no encryption'
|
||||
WHEN '1' THEN 'Unencrypted'
|
||||
WHEN '2' THEN 'Encryption in progress'
|
||||
WHEN '3' THEN 'Encrypted'
|
||||
WHEN '4' THEN 'Key change in progress'
|
||||
WHEN '5' THEN 'Decryption in progress'
|
||||
WHEN '6' THEN 'Protection change in progress (The certificate or asymmetric key that is encrypting the database encryption key is being changed.)'
|
||||
ELSE 'No Status'
|
||||
END
|
||||
,k.encryption_scan_state_desc
|
||||
,k.percent_complete
|
||||
,k.encryptor_thumbprint
|
||||
,k.encryptor_type
|
||||
FROM sys.dm_database_encryption_keys k;
|
||||
14
tde status.sql
Normal file
14
tde status.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
SELECT DB_NAME(database_id) AS DatabaseName, encryption_state,
|
||||
encryption_state_desc =
|
||||
CASE encryption_state
|
||||
WHEN '0' THEN 'No database encryption key present, no encryption'
|
||||
WHEN '1' THEN 'Unencrypted'
|
||||
WHEN '2' THEN 'Encryption in progress'
|
||||
WHEN '3' THEN 'Encrypted'
|
||||
WHEN '4' THEN 'Key change in progress'
|
||||
WHEN '5' THEN 'Decryption in progress'
|
||||
WHEN '6' THEN 'Protection change in progress (The certificate or asymmetric key that is encrypting the database encryption key is being changed.)'
|
||||
ELSE 'No Status'
|
||||
END,
|
||||
percent_complete,encryptor_thumbprint, encryptor_type FROM sys.dm_database_encryption_keys
|
||||
--WHERE DB_NAME(database_id) = 'database_name' --sepcify database
|
||||
50
update medifilm path.sql
Normal file
50
update medifilm path.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
Use ActivePos_server
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
DECLARE @ou_id INT
|
||||
EXEC Arizona.dbo.sp_bmc_Bmc_Applic_Default
|
||||
@in_job_type = 3,
|
||||
@in_param_int_1 = null, /* Company */
|
||||
@in_param_int_2 = null, /* Subsidiary */
|
||||
@in_param_varchar_1 = 'cvCurrentOrganizationalUnit',
|
||||
@out_default_value = @ou_id output,
|
||||
@out_param_int_1 = NULL
|
||||
|
||||
DECLARE @newVal NVARCHAR(500);
|
||||
|
||||
|
||||
/*Save the current value in [HCITools].[tmp].[TT_medifilm_setting]*/
|
||||
IF OBJECT_ID('[HCITools].[tmp].[TT_medifilm_setting]') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE [HCITools].[tmp].[TT_medifilm_setting](
|
||||
oldValue VARCHAR(MAX) NULL,
|
||||
dateChange DATETIME2(2) NOT NULL CONSTRAINT df_dateChange DEFAULT GETDATE()
|
||||
)
|
||||
END
|
||||
|
||||
/*dynamic sql to avoid exception because of non existing table while compiling the batch*/
|
||||
EXEC('
|
||||
INSERT INTO [HCITools].[tmp].[TT_medifilm_setting]([oldValue])
|
||||
SELECT [SE].[SettingValue]
|
||||
FROM [dbo].[Settings] SE
|
||||
where [SE].[SettingId] = ''Values.Global.SalesImportService.MainDirectory''
|
||||
')
|
||||
|
||||
/*Craft the new URI from the OU ofthe pharmacy*/
|
||||
SELECT @newVal = REPLACE('\\centralinfra.net\GAL\90_UserData\@ou@\POS\Medifilm', '@ou@', RTRIM(i.[Customer])+LTRIM(o.[OU_code]))
|
||||
FROM [Arizona].dbo.[Organizational_unit] [o]
|
||||
CROSS JOIN [master].cfg.[Identity] [i]
|
||||
WHERE [o].[Organizational_unit_ID] = @ou_id
|
||||
|
||||
/*Update the setting*/
|
||||
UPDATE se SET [SE].[SettingValue]= @newVal
|
||||
FROM [dbo].[Settings] SE (nolock)
|
||||
where [SE].[SettingId] = 'Values.Global.SalesImportService.MainDirectory'
|
||||
|
||||
/*restart the service to apply the change*/
|
||||
EXEC xp_cmdshell 'net stop arizonaServerService'
|
||||
EXEC xp_cmdshell 'net start arizonaServerService'
|
||||
|
||||
--COMMIT TRANSACTION
|
||||
ROLLBACK TRANSACTION
|
||||
50
used space in tables.sql
Normal file
50
used space in tables.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
use arizonald
|
||||
|
||||
SELECT t.name AS TableName,
|
||||
s.name AS SchemaName,
|
||||
-- [i].[name] AS indexName,
|
||||
MAX([p].[rows]) AS [rowCount],
|
||||
SUM([a].[total_pages]) * 8 AS TotalSpaceKB,
|
||||
CAST(ROUND(((SUM([a].[total_pages]) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
|
||||
SUM([a].[used_pages]) * 8 AS UsedSpaceKB,
|
||||
CAST(ROUND(((SUM([a].[used_pages]) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
|
||||
(SUM([a].[total_pages]) - SUM([a].[used_pages])) * 8 AS UnusedSpaceKB,
|
||||
CAST(ROUND(((SUM([a].[total_pages]) - SUM([a].[used_pages])) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
|
||||
FROM sys.tables t
|
||||
INNER JOIN sys.indexes i
|
||||
ON t.object_id = i.object_id
|
||||
INNER JOIN sys.partitions p
|
||||
ON i.object_id = p.object_id
|
||||
AND i.index_id = p.index_id
|
||||
INNER JOIN sys.allocation_units a
|
||||
ON [p].[partition_id] = [a].[container_id]
|
||||
LEFT OUTER JOIN sys.schemas s
|
||||
ON t.schema_id = s.schema_id
|
||||
WHERE i.object_id > 255
|
||||
AND i.index_id IN ( 0, 1 )
|
||||
AND t.name NOT LIKE 'dt%'
|
||||
AND [t].[is_ms_shipped] = 0
|
||||
AND i.object_id > 255
|
||||
GROUP BY t.name,
|
||||
s.name
|
||||
ORDER BY [TotalSpaceMB] DESC
|
||||
|
||||
RETURN
|
||||
|
||||
SELECT t.name AS TableName,
|
||||
MAX([p].[rows]) AS RowCounts,
|
||||
(SUM([a].[total_pages]) * 8) / 1024.0 AS TotalSpaceMB,
|
||||
(SUM([a].[used_pages]) * 8) / 1024.0 AS UsedSpaceMB,
|
||||
(SUM([a].[data_pages]) * 8) / 1024.0 AS DataSpaceMB
|
||||
FROM sys.tables t
|
||||
INNER JOIN sys.indexes i
|
||||
ON t.object_id = i.object_id
|
||||
INNER JOIN sys.partitions p
|
||||
ON i.object_id = p.object_id
|
||||
AND i.index_id = p.index_id
|
||||
INNER JOIN sys.allocation_units a
|
||||
ON [p].[partition_id] = [a].[container_id]
|
||||
WHERE i.object_id > 255
|
||||
AND i.index_id IN ( 0, 1 )
|
||||
GROUP BY t.name
|
||||
ORDER BY TotalSpaceMB DESC;
|
||||
7
wac1.sql
Normal file
7
wac1.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
EXEC master.dbo.sp_whoisactive
|
||||
@get_additional_info=0,@get_task_info=1, @output_column_list='[percent_complete][status][database_name][dd%][session_id][blocking_session_id][blocked_session_count][sql_text][sql_command][query_plan][login_name][wait_info][host_name][tasks][tran_log%][cpu%][temp%][block%][reads%][writes%][context%][physical%][locks][%]', @format_output=1
|
||||
,@get_plans=0
|
||||
,@get_outer_command=1
|
||||
,@get_locks = 0
|
||||
,@find_block_leaders = 1
|
||||
,@sort_order = '[blocked_session_count],[database_name],[sql_text],[dd hh:mm:ss.mss] DESC';
|
||||
Reference in New Issue
Block a user