From 63d058a7eb09a497d7ddb5e510017bd9eba17d46 Mon Sep 17 00:00:00 2001 From: "Schork Thierry (Galenica - ADM)" Date: Mon, 22 Sep 2025 09:00:00 +0200 Subject: [PATCH] added files from swmgmt03 --- CENT - reseed pharmindexTP identity.sql | 72 + Calculate waits over a time period.sql | 82 + ...nge dump device for arizona to u drive.sql | 49 + DBG - check snapshot isloation.sql | 8 + DBG - clean orphaned users.sql | 62 + DBG - find orphaned replication meta data.sql | 30 + ... generate disable change tracking cmds.sql | 41 + DBG - get all tables size.sql | 1 - DBG - get compatibility mode of all db's.sql | 17 + DBG - get list of sp in execution cache.sql | 23 + ...cking with restore of previous version.sql | Bin 0 -> 6398 bytes DBG - script job(s).sql | 339 + DBG - suspect database.sql | 16 + DELPHIX - arizonaCust cleanup.sql | 272 + DELPHIX - create target dbs.sql | 185 + ...hing a table in DB from another schema.sql | 27 + DELPHIX - get tables with change tracking.sql | 11 + ...ssion on db's to people in the project.sql | 96 + ...ssion on db's to people in the project.sql | 87 + DELPHIX - schema changes.sql | 346 ++ ...- used tables from central index usage.sql | 1130 ++++ DELPHIX DBG - restore arizona_delphix.sql | 68 + ...change compatibility mode for all db's.sql | 44 + EXPLOIT - check last full backup date.sql | 23 + EXPLOIT - disk usage and db size.sql | 134 + EXPLOIT - identity.sql | 4 + EXPLOIT - last db full backup.sql | 29 + ...OIT - missing db backup path 2 setting.sql | 35 + EXPLOIT - restart activePosClientService.sql | 3 + EXPLOIT - restart all distribution jobs.sql | 20 + EXPLOIT - start a job if not running.sql | 27 + ...rt replication agents that are stopped.sql | 28 + EXPLOIT - start replication.sql | 1 + EXPLOIT - syncro h gcmtestcent.sql | 163 + GAIA - delete data from short aliases.sql | 56 + HCI - BAG - sl2007_to_onprem publication.sql | 1230 ++++ ...rmine objects causing latch contention.sql | 78 + REPO - get auth.sql | Bin 0 -> 5922 bytes ..._Info_I3 with merge rather than insert.sql | Bin 0 -> 15570 bytes ...e Compression Savings Estimation Check.sql | 916 +++ amr not treated count.sql | 11 + bag mi create publication sl2007.sql | 12 + bag mi drop publication.sql | 34 + central index correction.sql | 114 + check gaia publication.sql | 38 + check restore history.sql | 16 + craft xml replication monitor.sql | 115 + ...alysis from extended event ring buffer.sql | 12 + deadlock extended events to ring buffer.sql | 10 + drop publication.sql | 7 + dump.sql | 1 + hcitools.dbo.Replication_Check.sql | Bin 0 -> 164152 bytes idx1.sql | 145 + last sp_configure call.sql | 67 + list pos.sql | 7 + new max memory setting.sql | 59 + orphaned users.sql | 17 + paul randal wait analysis.sql | 120 + repl.sql | 86 + ...h object owner before deletion of user.sql | 26 + sl2007 cloud publication scripted.sql | 988 +++ tde encryption status.sql | 21 + tde status.sql | 14 + update medifilm path.sql | 50 + used space in tables.sql | 50 + wac.sql | 5521 +++++++++++++++++ wac1.sql | 7 + 67 files changed, 13300 insertions(+), 1 deletion(-) create mode 100644 CENT - reseed pharmindexTP identity.sql create mode 100644 Calculate waits over a time period.sql create mode 100644 DBG - change dump device for arizona to u drive.sql create mode 100644 DBG - check snapshot isloation.sql create mode 100644 DBG - clean orphaned users.sql create mode 100644 DBG - find orphaned replication meta data.sql create mode 100644 DBG - generate disable change tracking cmds.sql create mode 100644 DBG - get compatibility mode of all db's.sql create mode 100644 DBG - get list of sp in execution cache.sql create mode 100644 DBG - re-enable change tracking with restore of previous version.sql create mode 100644 DBG - script job(s).sql create mode 100644 DBG - suspect database.sql create mode 100644 DELPHIX - arizonaCust cleanup.sql create mode 100644 DELPHIX - create target dbs.sql create mode 100644 DELPHIX - find FK referenching a table in DB from another schema.sql create mode 100644 DELPHIX - get tables with change tracking.sql create mode 100644 DELPHIX - give permission on db's to people in the project.sql create mode 100644 DELPHIX - remove permission on db's to people in the project.sql create mode 100644 DELPHIX - schema changes.sql create mode 100644 DELPHIX - used tables from central index usage.sql create mode 100644 DELPHIX DBG - restore arizona_delphix.sql create mode 100644 EXPLOIT - change compatibility mode for all db's.sql create mode 100644 EXPLOIT - check last full backup date.sql create mode 100644 EXPLOIT - disk usage and db size.sql create mode 100644 EXPLOIT - identity.sql create mode 100644 EXPLOIT - last db full backup.sql create mode 100644 EXPLOIT - missing db backup path 2 setting.sql create mode 100644 EXPLOIT - restart activePosClientService.sql create mode 100644 EXPLOIT - restart all distribution jobs.sql create mode 100644 EXPLOIT - start a job if not running.sql create mode 100644 EXPLOIT - start replication agents that are stopped.sql create mode 100644 EXPLOIT - start replication.sql create mode 100644 EXPLOIT - syncro h gcmtestcent.sql create mode 100644 GAIA - delete data from short aliases.sql create mode 100644 HCI - BAG - sl2007_to_onprem publication.sql create mode 100644 Query buffer descriptors to determine objects causing latch contention.sql create mode 100644 REPO - get auth.sql create mode 100644 SYNCRO H - aps_Sync_H_PH_Item_Regulation_Info_I3 with merge rather than insert.sql create mode 100644 Ultimate Compression Savings Estimation Check.sql create mode 100644 amr not treated count.sql create mode 100644 bag mi create publication sl2007.sql create mode 100644 bag mi drop publication.sql create mode 100644 central index correction.sql create mode 100644 check gaia publication.sql create mode 100644 check restore history.sql create mode 100644 craft xml replication monitor.sql create mode 100644 deadlock analysis from extended event ring buffer.sql create mode 100644 deadlock extended events to ring buffer.sql create mode 100644 drop publication.sql create mode 100644 dump.sql create mode 100644 hcitools.dbo.Replication_Check.sql create mode 100644 idx1.sql create mode 100644 last sp_configure call.sql create mode 100644 list pos.sql create mode 100644 new max memory setting.sql create mode 100644 orphaned users.sql create mode 100644 paul randal wait analysis.sql create mode 100644 repl.sql create mode 100644 search object owner before deletion of user.sql create mode 100644 sl2007 cloud publication scripted.sql create mode 100644 tde encryption status.sql create mode 100644 tde status.sql create mode 100644 update medifilm path.sql create mode 100644 used space in tables.sql create mode 100644 wac.sql create mode 100644 wac1.sql diff --git a/CENT - reseed pharmindexTP identity.sql b/CENT - reseed pharmindexTP identity.sql new file mode 100644 index 0000000..931e472 --- /dev/null +++ b/CENT - reseed pharmindexTP identity.sql @@ -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; \ No newline at end of file diff --git a/Calculate waits over a time period.sql b/Calculate waits over a time period.sql new file mode 100644 index 0000000..8a74e66 --- /dev/null +++ b/Calculate waits over a time period.sql @@ -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; \ No newline at end of file diff --git a/DBG - change dump device for arizona to u drive.sql b/DBG - change dump device for arizona to u drive.sql new file mode 100644 index 0000000..563a00a --- /dev/null +++ b/DBG - change dump device for arizona to u drive.sql @@ -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 + diff --git a/DBG - check snapshot isloation.sql b/DBG - check snapshot isloation.sql new file mode 100644 index 0000000..5e8cc86 --- /dev/null +++ b/DBG - check snapshot isloation.sql @@ -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 diff --git a/DBG - clean orphaned users.sql b/DBG - clean orphaned users.sql new file mode 100644 index 0000000..2e0fdf3 --- /dev/null +++ b/DBG - clean orphaned users.sql @@ -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 diff --git a/DBG - find orphaned replication meta data.sql b/DBG - find orphaned replication meta data.sql new file mode 100644 index 0000000..405c636 --- /dev/null +++ b/DBG - find orphaned replication meta data.sql @@ -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 \ No newline at end of file diff --git a/DBG - generate disable change tracking cmds.sql b/DBG - generate disable change tracking cmds.sql new file mode 100644 index 0000000..54ea081 --- /dev/null +++ b/DBG - generate disable change tracking cmds.sql @@ -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; diff --git a/DBG - get all tables size.sql b/DBG - get all tables size.sql index eefe9be..1c6cda9 100644 --- a/DBG - get all tables size.sql +++ b/DBG - get all tables size.sql @@ -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, diff --git a/DBG - get compatibility mode of all db's.sql b/DBG - get compatibility mode of all db's.sql new file mode 100644 index 0000000..5fd9fbb --- /dev/null +++ b/DBG - get compatibility mode of all db's.sql @@ -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 diff --git a/DBG - get list of sp in execution cache.sql b/DBG - get list of sp in execution cache.sql new file mode 100644 index 0000000..ea4b131 --- /dev/null +++ b/DBG - get list of sp in execution cache.sql @@ -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; diff --git a/DBG - re-enable change tracking with restore of previous version.sql b/DBG - re-enable change tracking with restore of previous version.sql new file mode 100644 index 0000000000000000000000000000000000000000..4f613918bbd89892553a66d00fa0a5b8832fd352 GIT binary patch literal 6398 zcmds*U2hUW6o${WiT{B+601ae-$V;Un}9{zL=)4Hg>LDly9=^tT7SIyyk~YpwMDsP z$YdAhV`t`_ch2XppMCpmed}7wzSy-*Ewh!)DY;d4VI5j8Ev2@gH?!NiZAvY%(q{CH z`C>_JYB!8f+t>=;1??Bi`(u3vZwaMpCzp;`^FwhuUFJHa!PBbKq|oC#wy`@zaur9r8kg#SG| zwl}QX{R8Fs1C+x@_Zu(^hfXE|p?340e?qO@x4j%#Sf^{}l>1}XXLL}HZPh0fW?i4t zkUfi^BRgcIPUMPR&RMC&diPOw>a*_DtB#$Me{m=l3V6?%N&hwb3(9VtWWxS(u>b#r zUOEDy*ewJ-_?mKmbvtzT$1W?0^Say$*`XubbyT^_b{Z|Bk-dYP1yYr|Mw4_c;46ba z$$ISgdNu&X2s9N>&NH*SXxVxwRSiE4Q#X5q?TkA(b6XbdV7xN+mRl!_R@q0SOx8ch z*f#oo7q#FfJOgl*poi1y5v1fEfXpzkAvGTi$(lWA*8OY+zQjJ_UhHSR%vus+EOOE$0O5Z<@DR!&& c34SK{P}khQ1;6t4#aCq?+!K*EvORCV0bcZQT>t<8 literal 0 HcmV?d00001 diff --git a/DBG - script job(s).sql b/DBG - script job(s).sql new file mode 100644 index 0000000..0430f6f --- /dev/null +++ b/DBG - script job(s).sql @@ -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 diff --git a/DBG - suspect database.sql b/DBG - suspect database.sql new file mode 100644 index 0000000..a8d8103 --- /dev/null +++ b/DBG - suspect database.sql @@ -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; diff --git a/DELPHIX - arizonaCust cleanup.sql b/DELPHIX - arizonaCust cleanup.sql new file mode 100644 index 0000000..35b07a3 --- /dev/null +++ b/DELPHIX - arizonaCust cleanup.sql @@ -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 \ No newline at end of file diff --git a/DELPHIX - create target dbs.sql b/DELPHIX - create target dbs.sql new file mode 100644 index 0000000..26d991f --- /dev/null +++ b/DELPHIX - create target dbs.sql @@ -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) + + diff --git a/DELPHIX - find FK referenching a table in DB from another schema.sql b/DELPHIX - find FK referenching a table in DB from another schema.sql new file mode 100644 index 0000000..c3a223f --- /dev/null +++ b/DELPHIX - find FK referenching a table in DB from another schema.sql @@ -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' \ No newline at end of file diff --git a/DELPHIX - get tables with change tracking.sql b/DELPHIX - get tables with change tracking.sql new file mode 100644 index 0000000..f1ff6cd --- /dev/null +++ b/DELPHIX - get tables with change tracking.sql @@ -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 \ No newline at end of file diff --git a/DELPHIX - give permission on db's to people in the project.sql b/DELPHIX - give permission on db's to people in the project.sql new file mode 100644 index 0000000..8487290 --- /dev/null +++ b/DELPHIX - give permission on db's to people in the project.sql @@ -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); \ No newline at end of file diff --git a/DELPHIX - remove permission on db's to people in the project.sql b/DELPHIX - remove permission on db's to people in the project.sql new file mode 100644 index 0000000..ba95bd3 --- /dev/null +++ b/DELPHIX - remove permission on db's to people in the project.sql @@ -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; diff --git a/DELPHIX - schema changes.sql b/DELPHIX - schema changes.sql new file mode 100644 index 0000000..2fbd7e3 --- /dev/null +++ b/DELPHIX - schema changes.sql @@ -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 diff --git a/DELPHIX - used tables from central index usage.sql b/DELPHIX - used tables from central index usage.sql new file mode 100644 index 0000000..f564ed3 --- /dev/null +++ b/DELPHIX - used tables from central index usage.sql @@ -0,0 +1,1130 @@ +USE [Arizona] + +DECLARE @usedTablesArizona TABLE( + id INT NOT NULL --IDENTITY + , tblName VARCHAR(222) NOT NULL +) + +--INSERT INTO @usedTablesArizona ([tblName]) +--SELECT [s].[ASI_schemaname]+'.'+[s].[ASI_tablename] +--FROM [arizonaCash].[HCITools].[dbo].[Aggregate_Stats_index] s +-- JOIN [Arizona].sys.[tables] t ON SCHEMA_NAME(t.[schema_id]) = s.[ASI_schemaname] AND t.[name] = s.[ASI_tablename] +--WHERE s.[ASI_databasename]='arizona' +--AND s.[ASI_updatedate] BETWEEN DATEADD(YEAR, -1, CURRENT_TIMESTAMP) AND CURRENT_TIMESTAMP +--AND ISNULL([s].[ASI_user_lookups], 0)+ISNULL([s].[ASI_user_scans],0)+ISNULL([s].[ASI_user_seeks],0)+ISNULL([s].[ASI_user_updates],0) > 0 +--AND [s].[ASI_tablename] NOT LIKE 'TT%' +--AND t.[is_ms_shipped] = 0 +--GROUP BY [s].[ASI_tablename], [s].[ASI_schemaname] +--ORDER BY [s].[ASI_schemaname], [s].[ASI_tablename] + +INSERT INTO @usedTablesArizona ([id], [tblName]) +VALUES +( 1, 'atl.Change_tracking_history' ), +( 2, 'atl.SQL_error_log' ), +( 3, 'crs.ProcessMessageLog' ), +( 4, 'dam.AMR_count_config' ), +( 5, 'dam.HashValueUniqueIndexGuid' ), +( 6, 'dam.HashValueUniqueIndexInt' ), +( 7, 'dam.MissingData' ), +( 8, 'dam.MonitorTableHash' ), +( 9, 'dbo.AC_profit_cost_type_link' ), +( 10, 'dbo.Acc_pre_cost_entry_link' ), +( 11, 'dbo.Acc_structure_master_text' ), +( 12, 'dbo.Account' ), +( 13, 'dbo.Account_ACPE_lock' ), +( 14, 'dbo.Account_balance' ), +( 15, 'dbo.Account_chart' ), +( 16, 'dbo.Account_credit_insurance' ), +( 17, 'dbo.Account_group' ), +( 18, 'dbo.Account_group_text' ), +( 19, 'dbo.Account_interest' ), +( 20, 'dbo.Account_interest_rate' ), +( 21, 'dbo.Account_interest_text' ), +( 22, 'dbo.Account_key' ), +( 23, 'dbo.Account_link' ), +( 24, 'dbo.Account_PD_link' ), +( 25, 'dbo.Account_structure' ), +( 26, 'dbo.Account_structure_master' ), +( 27, 'dbo.Account_structure_text' ), +( 28, 'dbo.Account_text' ), +( 29, 'dbo.Accounting_balance' ), +( 30, 'dbo.Accounting_balance_detail' ), +( 31, 'dbo.Accounting_period' ), +( 32, 'dbo.Accounting_plan' ), +( 33, 'dbo.Accounting_plan_text' ), +( 34, 'dbo.Accounting_turnover_agg' ), +( 35, 'dbo.ACG_pre_cost_entry_link' ), +( 36, 'dbo.ACG_profit_cost_type_link' ), +( 37, 'dbo.ACPE_weighting_detail' ), +( 38, 'dbo.ACPE_weighting_master' ), +( 39, 'dbo.ACPE_weighting_master_text' ), +( 40, 'dbo.ACS_account_list' ), +( 41, 'dbo.ACS_layout_detail' ), +( 42, 'dbo.ACS_layout_detail_text' ), +( 43, 'dbo.ACS_layout_master' ), +( 44, 'dbo.ACS_layout_master_text' ), +( 45, 'dbo.ACS_profit_cost_type_list' ), +( 46, 'dbo.ACS_totalizator_link' ), +( 47, 'dbo.Active_directory_user' ), +( 48, 'dbo.Activity' ), +( 49, 'dbo.Activity_prod_rate_default' ), +( 50, 'dbo.Activity_supplement' ), +( 51, 'dbo.Activity_supplement_text' ), +( 52, 'dbo.Activity_text' ), +( 53, 'dbo.Activity_type' ), +( 54, 'dbo.Activity_type_text' ), +( 55, 'dbo.Address' ), +( 56, 'dbo.Address_category' ), +( 57, 'dbo.Address_category_text' ), +( 58, 'dbo.Address_contact_person_list' ), +( 59, 'dbo.Address_criteria' ), +( 60, 'dbo.Address_distance_chart' ), +( 61, 'dbo.Address_group' ), +( 62, 'dbo.Address_group_text' ), +( 63, 'dbo.Address_invitation' ), +( 64, 'dbo.Address_invoicing_block' ), +( 65, 'dbo.Address_item_link' ), +( 66, 'dbo.Address_key' ), +( 67, 'dbo.Address_link' ), +( 68, 'dbo.Address_merge_prevalidation' ), +( 69, 'dbo.Address_monitor' ), +( 70, 'dbo.Address_remark' ), +( 71, 'dbo.Address_salutation' ), +( 72, 'dbo.Address_type' ), +( 73, 'dbo.Address_type_text' ), +( 74, 'dbo.Advert_support' ), +( 75, 'dbo.Advert_support_target' ), +( 76, 'dbo.Advert_support_type' ), +( 77, 'dbo.Advert_support_type_OU_cap' ), +( 78, 'dbo.Advert_support_type_text' ), +( 79, 'dbo.AGD_DL_link' ), +( 80, 'dbo.Agenda' ), +( 81, 'dbo.Alloy_detail' ), +( 82, 'dbo.Alloy_element' ), +( 83, 'dbo.Alloy_element_quantity' ), +( 84, 'dbo.Alloy_element_text' ), +( 85, 'dbo.Alloy_header' ), +( 86, 'dbo.Alloy_header_text' ), +( 87, 'dbo.Alloy_pre_transaction' ), +( 88, 'dbo.Alloy_pre_transaction_link' ), +( 89, 'dbo.Alloy_pre_transaction_text' ), +( 90, 'dbo.Alloy_processing_cost' ), +( 91, 'dbo.Alloy_transaction' ), +( 92, 'dbo.Application_default' ), +( 93, 'dbo.APS_connection_info' ), +( 94, 'dbo.APS_context_monitor' ), +( 95, 'dbo.APS_context_monitor_log' ), +( 96, 'dbo.APS_monitor_row' ), +( 97, 'dbo.APS_monitor_table' ), +( 98, 'dbo.APS_synchro_journal' ), +( 99, 'dbo.APS_tech_criteria_type' ), +( 100, 'dbo.APS_tech_criteria_type_text' ), +( 101, 'dbo.APS_version_hist_detail' ), +( 102, 'dbo.APS_version_history' ), +( 103, 'dbo.ASDP_detail' ), +( 104, 'dbo.Asset' ), +( 105, 'dbo.Asset_deprec_method_period' ), +( 106, 'dbo.Asset_family' ), +( 107, 'dbo.Asset_family_text' ), +( 108, 'dbo.Asset_group' ), +( 109, 'dbo.Asset_group_text' ), +( 110, 'dbo.Asset_history' ), +( 111, 'dbo.Asset_insurance' ), +( 112, 'dbo.Asset_investment_history' ), +( 113, 'dbo.Asset_leasing' ), +( 114, 'dbo.Asset_location' ), +( 115, 'dbo.Asset_location_text' ), +( 116, 'dbo.Asset_maintenance' ), +( 117, 'dbo.Assortment' ), +( 118, 'dbo.Assortment_item_link' ), +( 119, 'dbo.Assortment_text' ), +( 120, 'dbo.ATS_time_period_balance' ), +( 121, 'dbo.ATT_cust_list_column' ), +( 122, 'dbo.ATT_cust_list_column_text' ), +( 123, 'dbo.ATT_customized_list' ), +( 124, 'dbo.ATT_customized_list_text' ), +( 125, 'dbo.ATT_list_column_link' ), +( 126, 'dbo.ATT_time_period_balance' ), +( 127, 'dbo.ATT_time_period_constraint' ), +( 128, 'dbo.ATT_totalizator_link' ), +( 129, 'dbo.Automatic_data_acquisition' ), +( 130, 'dbo.AX_item_mappings_rules' ), +( 131, 'dbo.AX_user_data_area_mapping' ), +( 132, 'dbo.Bank_card' ), +( 133, 'dbo.Bank_card_detail' ), +( 134, 'dbo.Bank_card_transaction' ), +( 135, 'dbo.Batch_run' ), +( 136, 'dbo.Batch_type' ), +( 137, 'dbo.Batch_type_text' ), +( 138, 'dbo.Bmc_application_default' ), +( 139, 'dbo.Bmc_application_key' ), +( 140, 'dbo.Bmc_application_key_text' ), +( 141, 'dbo.Bmc_authorized_task' ), +( 142, 'dbo.Bmc_batch_type' ), +( 143, 'dbo.Bmc_batch_type_text' ), +( 144, 'dbo.Bmc_context' ), +( 145, 'dbo.Bmc_context_text' ), +( 146, 'dbo.Bmc_desktop_property' ), +( 147, 'dbo.Bmc_form_preference' ), +( 148, 'dbo.Bmc_form_property' ), +( 149, 'dbo.Bmc_group_level_security' ), +( 150, 'dbo.Bmc_ID_counter' ), +( 151, 'dbo.Bmc_license' ), +( 152, 'dbo.Bmc_license_task_link' ), +( 153, 'dbo.Bmc_role' ), +( 154, 'dbo.Bmc_role_text' ), +( 155, 'dbo.Bmc_row_level_security' ), +( 156, 'dbo.Bmc_system' ), +( 157, 'dbo.Bmc_task' ), +( 158, 'dbo.BMC_task_log' ), +( 159, 'dbo.Bmc_task_text' ), +( 160, 'dbo.Bmc_user_profile' ), +( 161, 'dbo.Bmc_user_role' ), +( 162, 'dbo.BMH_rule_type_link' ), +( 163, 'dbo.BML_rule_link' ), +( 164, 'dbo.BMOH_formula_variable' ), +( 165, 'dbo.BMOH_selected_rule' ), +( 166, 'dbo.BOM_header' ), +( 167, 'dbo.BOM_line' ), +( 168, 'dbo.BOM_location' ), +( 169, 'dbo.BOM_option_header' ), +( 170, 'dbo.BOM_revision' ), +( 171, 'dbo.BOM_rule' ), +( 172, 'dbo.BOM_rule_text' ), +( 173, 'dbo.BOM_rule_type' ), +( 174, 'dbo.BOM_rule_type_text' ), +( 175, 'dbo.Booth' ), +( 176, 'dbo.Brand' ), +( 177, 'dbo.Brand_AD_link' ), +( 178, 'dbo.Brand_OU_link' ), +( 179, 'dbo.Brand_text' ), +( 180, 'dbo.Budget_type' ), +( 181, 'dbo.Budget_type_text' ), +( 182, 'dbo.Button' ), +( 183, 'dbo.Button_text' ), +( 184, 'dbo.BVR_header' ), +( 185, 'dbo.BVR_line' ), +( 186, 'dbo.BVR_member' ), +( 187, 'dbo.BVR_type' ), +( 188, 'dbo.Calendar_detail' ), +( 189, 'dbo.Calendar_header' ), +( 190, 'dbo.Calendar_header_text' ), +( 191, 'dbo.Card' ), +( 192, 'dbo.Cash_report_header' ), +( 193, 'dbo.Cash_report_line' ), +( 194, 'dbo.CCI_ATA_guarantee' ), +( 195, 'dbo.CLK_group' ), +( 196, 'dbo.CLK_group_text' ), +( 197, 'dbo.CLK_user_interface' ), +( 198, 'dbo.Clocking' ), +( 199, 'dbo.Clocking_key' ), +( 200, 'dbo.Clocking_message' ), +( 201, 'dbo.Clocking_message_text' ), +( 202, 'dbo.Clocking_summary' ), +( 203, 'dbo.Clocking_terminal' ), +( 204, 'dbo.Clocking_terminal_profile' ), +( 205, 'dbo.CLT_authorized_CLKG' ), +( 206, 'dbo.CLTP_schedule' ), +( 207, 'dbo.CLTP_user_interface' ), +( 208, 'dbo.CNCI_addr' ), +( 209, 'dbo.Comm_price_master_text' ), +( 210, 'dbo.Commercial_price_detail' ), +( 211, 'dbo.Commercial_price_master' ), +( 212, 'dbo.Communication_history' ), +( 213, 'dbo.Company' ), +( 214, 'dbo.Contact_person' ), +( 215, 'dbo.Contract_daily_time' ), +( 216, 'dbo.Contract_daily_time_detail' ), +( 217, 'dbo.Contract_time_adjustment' ), +( 218, 'dbo.Contract_time_table_date' ), +( 219, 'dbo.Contract_time_table_detail' ), +( 220, 'dbo.Contract_time_table_header' ), +( 221, 'dbo.Cost_acc_plausibility' ), +( 222, 'dbo.Cost_accounting_type' ), +( 223, 'dbo.Cost_accounting_type_text' ), +( 224, 'dbo.Cost_entry' ), +( 225, 'dbo.Country' ), +( 226, 'dbo.Country_text' ), +( 227, 'dbo.CR_receipt_detail' ), +( 228, 'dbo.CR_receipt_input_schema' ), +( 229, 'dbo.CR_receipt_master' ), +( 230, 'dbo.CR_receipt_POS' ), +( 231, 'dbo.Credit_card_company' ), +( 232, 'dbo.Criteria' ), +( 233, 'dbo.Criteria_schema_detail' ), +( 234, 'dbo.Criteria_schema_header' ), +( 235, 'dbo.Criteria_schema_values' ), +( 236, 'dbo.Criteria_text' ), +( 237, 'dbo.Criteria_type' ), +( 238, 'dbo.Criteria_type_text' ), +( 239, 'dbo.CRS_batch_run' ), +( 240, 'dbo.CRS_document_header' ), +( 241, 'dbo.CSH_text' ), +( 242, 'dbo.Currency' ), +( 243, 'dbo.Currency_account' ), +( 244, 'dbo.Currency_rate' ), +( 245, 'dbo.Currency_text' ), +( 246, 'dbo.CUST_ITCOSTA_Spaceman_conversion' ), +( 247, 'dbo.Custom_export_licence' ), +( 248, 'dbo.Custom_export_licence_text' ), +( 249, 'dbo.Customer' ), +( 250, 'dbo.Customer_card' ), +( 251, 'dbo.Data_interface_status' ), +( 252, 'dbo.DBA_change_tracking' ), +( 253, 'dbo.DBA_change_tracking_DWH' ), +( 254, 'dbo.DBA_change_tracking_template' ), +( 255, 'dbo.DBA_change_tracking_version' ), +( 256, 'dbo.DBA_Mailing_list' ), +( 257, 'dbo.DBA_Servers_Monitoring' ), +( 258, 'dbo.DBA_Working_hours' ), +( 259, 'dbo.Default_journal' ), +( 260, 'dbo.Deleted_Lore_Item_Facing' ), +( 261, 'dbo.Delivery_code' ), +( 262, 'dbo.Delivery_code_text' ), +( 263, 'dbo.Delivery_cost' ), +( 264, 'dbo.Delivery_cost_DC_link' ), +( 265, 'dbo.Delivery_cost_detail' ), +( 266, 'dbo.Delivery_cost_text' ), +( 267, 'dbo.Department' ), +( 268, 'dbo.Department_text' ), +( 269, 'dbo.Depreciation_method' ), +( 270, 'dbo.Depreciation_method_period' ), +( 271, 'dbo.DH_address_link' ), +( 272, 'dbo.DH_criteria' ), +( 273, 'dbo.DH_customer_card_link' ), +( 274, 'dbo.DH_facility_link' ), +( 275, 'dbo.DH_loyalty_card' ), +( 276, 'dbo.DH_pre_calc_header' ), +( 277, 'dbo.DH_pre_calc_quantity' ), +( 278, 'dbo.DH_pre_calc_surplus' ), +( 279, 'dbo.DH_signature' ), +( 280, 'dbo.DH_status_history' ), +( 281, 'dbo.DiscountVoucher' ), +( 282, 'dbo.DiscountVoucher_FS_link' ), +( 283, 'dbo.DiscountVoucherCondition' ), +( 284, 'dbo.DiscountVoucherLinkOU' ), +( 285, 'dbo.DiscountVoucherText' ), +( 286, 'dbo.DL_alloy_batch' ), +( 287, 'dbo.DL_BML_link' ), +( 288, 'dbo.DL_criteria' ), +( 289, 'dbo.DL_planning' ), +( 290, 'dbo.DL_posology' ), +( 291, 'dbo.DL_pre_calc_material' ), +( 292, 'dbo.DL_pre_calc_process_line' ), +( 293, 'dbo.DL_quantity_formula' ), +( 294, 'dbo.DL_unit_price_breakdown' ), +( 295, 'dbo.DL_WKOP_link' ), +( 296, 'dbo.Doc_header_customs_info' ), +( 297, 'dbo.Document_copy' ), +( 298, 'dbo.Document_counter' ), +( 299, 'dbo.Document_date' ), +( 300, 'dbo.Document_error' ), +( 301, 'dbo.Document_error_link' ), +( 302, 'dbo.Document_header' ), +( 303, 'dbo.Document_header_link' ), +( 304, 'dbo.Document_header_revision' ), +( 305, 'dbo.Document_header_text' ), +( 306, 'dbo.Document_line' ), +( 307, 'dbo.Document_line_date' ), +( 308, 'dbo.Document_line_link' ), +( 309, 'dbo.Document_periodicity' ), +( 310, 'dbo.Document_periodicity_date' ), +( 311, 'dbo.Document_transfer_method' ), +( 312, 'dbo.Document_type' ), +( 313, 'dbo.Document_type_text' ), +( 314, 'dbo.DT_address' ), +( 315, 'dbo.DT_cash_register' ), +( 316, 'dbo.DT_device' ), +( 317, 'dbo.DT_document_header' ), +( 318, 'dbo.DT_document_line' ), +( 319, 'dbo.DT_registration' ), +( 320, 'dbo.DT_registration_address' ), +( 321, 'dbo.DVACSpecificTargetItem' ), +( 322, 'dbo.DVActionDefinition' ), +( 323, 'dbo.DVCouponActionDefinition' ), +( 324, 'dbo.DVCouponActionDefinitionText' ), +( 325, 'dbo.DVCouponActionDefPrinting' ), +( 326, 'dbo.DVPackageElement' ), +( 327, 'dbo.DWT_Item_Search_Itk' ), +( 328, 'dbo.DWT_Item_Search_Ittx' ), +( 329, 'dbo.DWT_Item_Search_PHGDSC' ), +( 330, 'dbo.EAS_APS_address_link' ), +( 331, 'dbo.EAS_APS_op_link_text' ), +( 332, 'dbo.EAS_APS_operation_link' ), +( 333, 'dbo.EAS_file_header' ), +( 334, 'dbo.EAS_file_line' ), +( 335, 'dbo.EAS_structure' ), +( 336, 'dbo.EAS_structure_operation' ), +( 337, 'dbo.EAS_structure_text' ), +( 338, 'dbo.EAS_structure_trigger' ), +( 339, 'dbo.EDI_DTA' ), +( 340, 'dbo.EDI_DTA_entry_link' ), +( 341, 'dbo.EDI_DTA_PCA_payment_link' ), +( 342, 'dbo.EDI_DTA_PIH_link' ), +( 343, 'dbo.EDI_DTA_structure' ), +( 344, 'dbo.EDI_DTA_structure_text' ), +( 345, 'dbo.Effective_pre_cost_entry' ), +( 346, 'dbo.Effective_pre_entry_link' ), +( 347, 'dbo.Effective_preliminary_entry' ), +( 348, 'dbo.Effective_time' ), +( 349, 'dbo.EFT_OW_method' ), +( 350, 'dbo.EFT_OW_method_text' ), +( 351, 'dbo.EFT_OW_pre_entry' ), +( 352, 'dbo.EFT_OW_rule' ), +( 353, 'dbo.EFT_terminal' ), +( 354, 'dbo.EFT_terminal_OU_link' ), +( 355, 'dbo.EFT_terminal_text' ), +( 356, 'dbo.Element_account' ), +( 357, 'dbo.Element_transaction' ), +( 358, 'dbo.Email_pattern' ), +( 359, 'dbo.EMC_absence' ), +( 360, 'dbo.EMC_certificate_layout' ), +( 361, 'dbo.EMC_criteria' ), +( 362, 'dbo.EMC_loan' ), +( 363, 'dbo.EMC_multi_profile' ), +( 364, 'dbo.EMC_payment_method' ), +( 365, 'dbo.EMC_payroll_period' ), +( 366, 'dbo.EMC_payroll_variable' ), +( 367, 'dbo.EMC_periodicity' ), +( 368, 'dbo.EMC_termination_reason' ), +( 369, 'dbo.EMC_termination_reason_text' ), +( 370, 'dbo.EMC_termination_type' ), +( 371, 'dbo.EMC_termination_type_text' ), +( 372, 'dbo.EMCH_payroll_period_link' ), +( 373, 'dbo.Employee' ), +( 374, 'dbo.Employee_work_plan' ), +( 375, 'dbo.Employment_contract' ), +( 376, 'dbo.Employment_contract_history' ), +( 377, 'dbo.Ems_address' ), +( 378, 'dbo.EMS_deposit' ), +( 379, 'dbo.Ems_room' ), +( 380, 'dbo.Ems_stay' ), +( 381, 'dbo.EMSS_DL_link' ), +( 382, 'dbo.Entry' ), +( 383, 'dbo.Entry_key' ), +( 384, 'dbo.Entry_link' ), +( 385, 'dbo.Entry_reconciliation' ), +( 386, 'dbo.Entry_type' ), +( 387, 'dbo.Entry_type_text' ), +( 388, 'dbo.EPD_provider' ), +( 389, 'dbo.EPP_status_history' ), +( 390, 'dbo.ERP_role' ), +( 391, 'dbo.ERP_role_mapping' ), +( 392, 'dbo.ERP_role_text' ), +( 393, 'dbo.Ethnic_group' ), +( 394, 'dbo.Ethnic_group_text' ), +( 395, 'dbo.Event' ), +( 396, 'dbo.Event_catalogue' ), +( 397, 'dbo.Event_catalogue_link' ), +( 398, 'dbo.Event_contact_address' ), +( 399, 'dbo.Event_premise' ), +( 400, 'dbo.Event_registration' ), +( 401, 'dbo.Event_sector' ), +( 402, 'dbo.Event_service' ), +( 403, 'dbo.External_entry' ), +( 404, 'dbo.External_file' ), +( 405, 'dbo.External_file_section' ), +( 406, 'dbo.External_file_section_text' ), +( 407, 'dbo.External_file_text' ), +( 408, 'dbo.External_preliminary_entry' ), +( 409, 'dbo.FA_account_periodicity' ), +( 410, 'dbo.FA_RAFAM_type' ), +( 411, 'dbo.FA_RAFAM_type_text' ), +( 412, 'dbo.Facility' ), +( 413, 'dbo.Facility_address_link' ), +( 414, 'dbo.Facility_technical_criteria' ), +( 415, 'dbo.Family_allowance' ), +( 416, 'dbo.Family_allowance_account' ), +( 417, 'dbo.Family_allowance_history' ), +( 418, 'dbo.Family_allowance_journal' ), +( 419, 'dbo.Family_allowance_tariff' ), +( 420, 'dbo.Family_technical_criteria' ), +( 421, 'dbo.Filestream' ), +( 422, 'dbo.Financial_institution' ), +( 423, 'dbo.Financial_relation_account' ), +( 424, 'dbo.Fiscal_year' ), +( 425, 'dbo.Fixed_price' ), +( 426, 'dbo.Form_property_model' ), +( 427, 'dbo.FP_unit_price_breakdown' ), +( 428, 'dbo.FTC_authorized_value' ), +( 429, 'dbo.FUN_OUSH_link' ), +( 430, 'dbo.Hotline' ), +( 431, 'dbo.HR_certificate' ), +( 432, 'dbo.HR_certificate_text' ), +( 433, 'dbo.HR_evaluation_detail' ), +( 434, 'dbo.HR_evaluation_master' ), +( 435, 'dbo.HR_header' ), +( 436, 'dbo.HR_language_skill' ), +( 437, 'dbo.HR_prof_experience' ), +( 438, 'dbo.HR_skill' ), +( 439, 'dbo.HR_skill_level' ), +( 440, 'dbo.HR_skill_level_text' ), +( 441, 'dbo.HR_skill_type' ), +( 442, 'dbo.HR_skill_type_text' ), +( 443, 'dbo.HR_training' ), +( 444, 'dbo.HR_training_attendee' ), +( 445, 'dbo.HR_training_course' ), +( 446, 'dbo.HR_training_course_text' ), +( 447, 'dbo.HR_training_field' ), +( 448, 'dbo.HR_training_field_text' ), +( 449, 'dbo.HR_training_type' ), +( 450, 'dbo.HR_training_type_text' ), +( 451, 'dbo.HR_warning' ), +( 452, 'dbo.Incident_detail' ), +( 453, 'dbo.Incident_header' ), +( 454, 'dbo.Incident_type' ), +( 455, 'dbo.Incident_type_text' ), +( 456, 'dbo.IND_DH_link' ), +( 457, 'dbo.IND_status_history' ), +( 458, 'dbo.INS_PD_link' ), +( 459, 'dbo.Insurance_network' ), +( 460, 'dbo.Insurance_network_text' ), +( 461, 'dbo.Insurance_policy' ), +( 462, 'dbo.INT_PD_link' ), +( 463, 'dbo.Inter_OU_entry' ), +( 464, 'dbo.Inter_OU_pre_entry' ), +( 465, 'dbo.Inter_OU_pre_ET_master' ), +( 466, 'dbo.Inter_OU_pre_ET_master_text' ), +( 467, 'dbo.Interco_structure' ), +( 468, 'dbo.Interco_structure_target' ), +( 469, 'dbo.Interco_synchronization' ), +( 470, 'dbo.Interco_task' ), +( 471, 'dbo.Interco_task_PD_link' ), +( 472, 'dbo.Interco_task_text' ), +( 473, 'dbo.Inventory_batch' ), +( 474, 'dbo.Inventory_location' ), +( 475, 'dbo.Inventory_site' ), +( 476, 'dbo.Inventory_type' ), +( 477, 'dbo.Inventory_type_text' ), +( 478, 'dbo.Invitation' ), +( 479, 'dbo.Invoicing_method' ), +( 480, 'dbo.Invoicing_method_text' ), +( 481, 'dbo.IT_categ_management_text' ), +( 482, 'dbo.IT_category_management' ), +( 483, 'dbo.IT_change_request' ), +( 484, 'dbo.IT_config_setting' ), +( 485, 'dbo.IT_ITCM_history' ), +( 486, 'dbo.IT_label_print_log' ), +( 487, 'dbo.IT_weighing_category' ), +( 488, 'dbo.IT_weighing_category_text' ), +( 489, 'dbo.ITCAT_IT_link' ), +( 490, 'dbo.ITCAT_OUST_link' ), +( 491, 'dbo.ITCHR_consequence' ), +( 492, 'dbo.ITCHR_item_link' ), +( 493, 'dbo.ITCHR_status_history' ), +( 494, 'dbo.ITCOSTA_CR_link' ), +( 495, 'dbo.Item' ), +( 496, 'dbo.Item_alloy' ), +( 497, 'dbo.Item_alloy_quantity' ), +( 498, 'dbo.Item_attachment' ), +( 499, 'dbo.Item_catalog' ), +( 500, 'dbo.Item_catalog_text' ), +( 501, 'dbo.Item_context' ), +( 502, 'dbo.Item_context_status' ), +( 503, 'dbo.Item_context_status_text' ), +( 504, 'dbo.Item_context_text' ), +( 505, 'dbo.Item_criteria' ), +( 506, 'dbo.Item_dispatch_header' ), +( 507, 'dbo.Item_dispatch_line' ), +( 508, 'dbo.Item_family' ), +( 509, 'dbo.Item_family_text' ), +( 510, 'dbo.Item_group' ), +( 511, 'dbo.Item_group_def_accounting' ), +( 512, 'dbo.Item_group_text' ), +( 513, 'dbo.Item_inventory' ), +( 514, 'dbo.Item_key' ), +( 515, 'dbo.Item_link' ), +( 516, 'dbo.Item_location' ), +( 517, 'dbo.Item_LORE_min_max' ), +( 518, 'dbo.Item_manufacturing' ), +( 519, 'dbo.Item_price_range' ), +( 520, 'dbo.Item_price_range_text' ), +( 521, 'dbo.Item_process' ), +( 522, 'dbo.Item_purchase' ), +( 523, 'dbo.Item_quantity' ), +( 524, 'dbo.Item_regulation' ), +( 525, 'dbo.Item_relation_info' ), +( 526, 'dbo.Item_revision' ), +( 527, 'dbo.Item_sale' ), +( 528, 'dbo.Item_seasonal_stock_info' ), +( 529, 'dbo.Item_shipping' ), +( 530, 'dbo.Item_site' ), +( 531, 'dbo.Item_standard_cost' ), +( 532, 'dbo.Item_statistics' ), +( 533, 'dbo.Item_statistics_monthly' ), +( 534, 'dbo.Item_statistics_yearly' ), +( 535, 'dbo.Item_status_history' ), +( 536, 'dbo.Item_technical_criteria' ), +( 537, 'dbo.Item_terms' ), +( 538, 'dbo.Item_text' ), +( 539, 'dbo.Item_text_planned' ), +( 540, 'dbo.Item_unit_conversion' ), +( 541, 'dbo.ITTC_history' ), +( 542, 'dbo.JAL_authorized_ACPE' ), +( 543, 'dbo.Job_function' ), +( 544, 'dbo.Job_function_text' ), +( 545, 'dbo.Journal' ), +( 546, 'dbo.Knowledge_base' ), +( 547, 'dbo.Knowledge_base_category' ), +( 548, 'dbo.Knowledge_base_key' ), +( 549, 'dbo.Knowledge_category' ), +( 550, 'dbo.Knowledge_category_text' ), +( 551, 'dbo.LAN_app_equivalence' ), +( 552, 'dbo.Language' ), +( 553, 'dbo.Language_text' ), +( 554, 'dbo.Leasing' ), +( 555, 'dbo.Ledger' ), +( 556, 'dbo.Ledger_text' ), +( 557, 'dbo.Linked_document' ), +( 558, 'dbo.LORE_average_sales_qty' ), +( 559, 'dbo.LORE_calculation_log' ), +( 560, 'dbo.LORE_Delivery_By_Day' ), +( 561, 'dbo.LORE_evaluation_period' ), +( 562, 'dbo.LORE_item_ABC_code' ), +( 563, 'dbo.LORE_item_facing' ), +( 564, 'dbo.LORE_management_level' ), +( 565, 'dbo.LORE_poisson_coefficient' ), +( 566, 'dbo.LORE_rotation_ABC' ), +( 567, 'dbo.LORE_rotation_ABC_detail' ), +( 568, 'dbo.LORE_service_level_rate' ), +( 569, 'dbo.LORE_statistical_period' ), +( 570, 'dbo.LORE_store_opening_days' ), +( 571, 'dbo.LORE_supplying_procedure' ), +( 572, 'dbo.LORE_wilson_corr_fact_criteria' ), +( 573, 'dbo.LORE_wilson_correction_factor' ), +( 574, 'dbo.LORE_wilson_interest_rate' ), +( 575, 'dbo.LORE_wilson_logistics_cost' ), +( 576, 'dbo.LORE_wilson_purchasing_cost' ), +( 577, 'dbo.LORE_z_coefficient' ), +( 578, 'dbo.Loyalty_card' ), +( 579, 'dbo.Machine' ), +( 580, 'dbo.Machine_downtime' ), +( 581, 'dbo.Machine_text' ), +( 582, 'dbo.Machine_time' ), +( 583, 'dbo.MAFAM_item_link' ), +( 584, 'dbo.MAG_ad' ), +( 585, 'dbo.MAG_ad_item' ), +( 586, 'dbo.MAG_ad_status_history' ), +( 587, 'dbo.MAG_ad_type' ), +( 588, 'dbo.MAG_ad_type_text' ), +( 589, 'dbo.MAG_page' ), +( 590, 'dbo.MAG_status_history' ), +( 591, 'dbo.MAGAD_DL_link' ), +( 592, 'dbo.MAGAD_technical_criteria' ), +( 593, 'dbo.Magazine' ), +( 594, 'dbo.Magazine_type' ), +( 595, 'dbo.Magazine_type_text' ), +( 596, 'dbo.Maintenance' ), +( 597, 'dbo.Maintenance_contract' ), +( 598, 'dbo.Manual_clocking' ), +( 599, 'dbo.Manufacturer' ), +( 600, 'dbo.Margin_class' ), +( 601, 'dbo.Margin_class_text' ), +( 602, 'dbo.Margin_factor_detail' ), +( 603, 'dbo.Margin_factor_master' ), +( 604, 'dbo.Margin_factor_master_text' ), +( 605, 'dbo.Marital_status' ), +( 606, 'dbo.Marketing_action_detail' ), +( 607, 'dbo.Marketing_activity_header' ), +( 608, 'dbo.Marketing_type' ), +( 609, 'dbo.Marketing_type_text' ), +( 610, 'dbo.Material_requirement' ), +( 611, 'dbo.Material_requirement_link' ), +( 612, 'dbo.Modifier_definition' ), +( 613, 'dbo.Modifier_exclusion' ), +( 614, 'dbo.MRP_log' ), +( 615, 'dbo.Numerary_value' ), +( 616, 'dbo.Object_merge_log' ), +( 617, 'dbo.Occupation' ), +( 618, 'dbo.Occupation_text' ), +( 619, 'dbo.OFFCLD_reject' ), +( 620, 'dbo.Offline_clocking' ), +( 621, 'dbo.Offline_clocking_detail' ), +( 622, 'dbo.Operation' ), +( 623, 'dbo.Operation_role' ), +( 624, 'dbo.OPT_DH_info' ), +( 625, 'dbo.OPT_measure' ), +( 626, 'dbo.OPT_task_info' ), +( 627, 'dbo.Organizational_unit' ), +( 628, 'dbo.OU_advertising_space' ), +( 629, 'dbo.OU_authorized_interco_task' ), +( 630, 'dbo.OU_authorized_PD' ), +( 631, 'dbo.OU_group' ), +( 632, 'dbo.OU_group_link' ), +( 633, 'dbo.OU_group_text' ), +( 634, 'dbo.OU_item_link' ), +( 635, 'dbo.OU_manager' ), +( 636, 'dbo.OU_price_code_priority' ), +( 637, 'dbo.OU_store_history' ), +( 638, 'dbo.OU_store_history_2016_08_22' ), +( 639, 'dbo.OU_store_type' ), +( 640, 'dbo.OU_store_type_budget' ), +( 641, 'dbo.OU_store_type_text' ), +( 642, 'dbo.OU_user_role' ), +( 643, 'dbo.OUAS_DL_link' ), +( 644, 'dbo.OUAS_technical_criteria' ), +( 645, 'dbo.Package_detail' ), +( 646, 'dbo.Package_doc_line_link' ), +( 647, 'dbo.Package_header' ), +( 648, 'dbo.Packing_list' ), +( 649, 'dbo.Packing_type' ), +( 650, 'dbo.Packing_type_text' ), +( 651, 'dbo.Payment_input_detail' ), +( 652, 'dbo.Payment_input_header' ), +( 653, 'dbo.Payment_method' ), +( 654, 'dbo.Payment_method_text' ), +( 655, 'dbo.Payment_proposal_bank' ), +( 656, 'dbo.Payment_proposal_batch' ), +( 657, 'dbo.Payment_terms' ), +( 658, 'dbo.Payment_terms_detail' ), +( 659, 'dbo.Payment_terms_text' ), +( 660, 'dbo.Payroll_batch' ), +( 661, 'dbo.Payroll_batch_bank' ), +( 662, 'dbo.Payroll_batch_detail' ), +( 663, 'dbo.Payroll_calc_detail' ), +( 664, 'dbo.Payroll_calculation' ), +( 665, 'dbo.Payroll_employee_profile' ), +( 666, 'dbo.Payroll_heading' ), +( 667, 'dbo.Payroll_heading_specs' ), +( 668, 'dbo.Payroll_heading_text' ), +( 669, 'dbo.Payroll_parameters' ), +( 670, 'dbo.Payroll_period' ), +( 671, 'dbo.Payroll_period_master' ), +( 672, 'dbo.Payroll_period_master_text' ), +( 673, 'dbo.Payroll_period_text' ), +( 674, 'dbo.Payroll_period_type' ), +( 675, 'dbo.Payroll_period_type_text' ), +( 676, 'dbo.Payroll_profile_detail' ), +( 677, 'dbo.Payroll_profile_master' ), +( 678, 'dbo.Payroll_profile_master_text' ), +( 679, 'dbo.Payroll_scale_date' ), +( 680, 'dbo.Payroll_scale_detail' ), +( 681, 'dbo.Payroll_scale_master' ), +( 682, 'dbo.Payroll_scale_master_text' ), +( 683, 'dbo.PCA_EMC_absence' ), +( 684, 'dbo.PCA_EMC_loan' ), +( 685, 'dbo.PCA_payment_method' ), +( 686, 'dbo.PCC_totalizator_link' ), +( 687, 'dbo.PCT_totalizator_link' ), +( 688, 'dbo.PD_default_address_link' ), +( 689, 'dbo.PD_item_group_link' ), +( 690, 'dbo.PD_link' ), +( 691, 'dbo.PD_minimum_amount' ), +( 692, 'dbo.PD_pre_cost_entry_link' ), +( 693, 'dbo.pda_CRM_reprocessing' ), +( 694, 'dbo.PEM_amount_breakdown' ), +( 695, 'dbo.PerformancePoint' ), +( 696, 'dbo.PerformancePointAggregation' ), +( 697, 'dbo.Periodic_document_model' ), +( 698, 'dbo.Periodicity_detail' ), +( 699, 'dbo.Periodicity_master' ), +( 700, 'dbo.Periodicity_master_text' ), +( 701, 'dbo.Periodicity_type' ), +( 702, 'dbo.Periodicity_type_text' ), +( 703, 'dbo.PH_APOS_item_status' ), +( 704, 'dbo.PH_Clinical_Check' ), +( 705, 'dbo.PH_Clinical_Check_Text' ), +( 706, 'dbo.PH_Clinical_Check_Type' ), +( 707, 'dbo.PH_Clinical_Check_Type_Text' ), +( 708, 'dbo.PH_custom_insurance_plan' ), +( 709, 'dbo.PH_ins_plan_pattern' ), +( 710, 'dbo.PH_ins_plan_pattern_master' ), +( 711, 'dbo.PH_ins_plan_refund_link' ), +( 712, 'dbo.PH_insurance' ), +( 713, 'dbo.PH_insurance_agreement' ), +( 714, 'dbo.PH_insurance_card' ), +( 715, 'dbo.PH_insurance_card_validation_history' ), +( 716, 'dbo.PH_insurance_group' ), +( 717, 'dbo.PH_insurance_group_link' ), +( 718, 'dbo.PH_insurance_group_text' ), +( 719, 'dbo.PH_insurance_history' ), +( 720, 'dbo.PH_insurance_plan' ), +( 721, 'dbo.PH_insurance_recommendation' ), +( 722, 'dbo.PH_insurance_supplement' ), +( 723, 'dbo.PH_insurance_tax_link' ), +( 724, 'dbo.PH_invoice_header' ), +( 725, 'dbo.PH_item' ), +( 726, 'dbo.PH_item_commercial_rule' ), +( 727, 'dbo.PH_item_insurance_link' ), +( 728, 'dbo.PH_item_limitation' ), +( 729, 'dbo.PH_item_regulation_info' ), +( 730, 'dbo.PH_OICM_code' ), +( 731, 'dbo.PH_OICM_code_text' ), +( 732, 'dbo.PH_OICM_history' ), +( 733, 'dbo.PH_organizational_unit' ), +( 734, 'dbo.PH_patient' ), +( 735, 'dbo.PH_patient_clinical_check' ), +( 736, 'dbo.PH_patient_tax_link' ), +( 737, 'dbo.PH_payment_receipt' ), +( 738, 'dbo.PH_PHIPM_text' ), +( 739, 'dbo.PH_posology_code' ), +( 740, 'dbo.PH_posology_code_text' ), +( 741, 'dbo.PH_prescriber' ), +( 742, 'dbo.PH_Prescriber_ins_link' ), +( 743, 'dbo.PH_prescriber_role' ), +( 744, 'dbo.PH_prescription_header' ), +( 745, 'dbo.PH_prescription_line' ), +( 746, 'dbo.PH_product' ), +( 747, 'dbo.PH_refund_code' ), +( 748, 'dbo.PH_refund_code_relation' ), +( 749, 'dbo.PH_refund_code_text' ), +( 750, 'dbo.PH_sales_import' ), +( 751, 'dbo.PH_spec_tariff_addr_link' ), +( 752, 'dbo.PH_spec_tariff_detail' ), +( 753, 'dbo.PH_spec_tariff_master' ), +( 754, 'dbo.PH_spec_tariff_master_txt' ), +( 755, 'dbo.PH_std_posology' ), +( 756, 'dbo.PH_std_posology_text' ), +( 757, 'dbo.PH_tax_history' ), +( 758, 'dbo.Pharmacy_indicator' ), +( 759, 'dbo.PHGD_ACSC' ), +( 760, 'dbo.PHGD_ACXI' ), +( 761, 'dbo.PHGD_Brevier' ), +( 762, 'dbo.PHGD_BrevierText' ), +( 763, 'dbo.PHGD_CODES' ), +( 764, 'dbo.PHGD_CODETXT' ), +( 765, 'dbo.PHGD_CommonStyleSheet' ), +( 766, 'dbo.PHGD_Compendium' ), +( 767, 'dbo.PHGD_CompendiumParagraph' ), +( 768, 'dbo.PHGD_CompendiumText' ), +( 769, 'dbo.PHGD_LIMITATION' ), +( 770, 'dbo.PHGD_LIMITTXT' ), +( 771, 'dbo.PHGD_product_form' ), +( 772, 'dbo.PHGD_SC' ), +( 773, 'dbo.PHGD_XI' ), +( 774, 'dbo.PHGD_XIM' ), +( 775, 'dbo.PHGD_XITXT' ), +( 776, 'dbo.PHID_alloy' ), +( 777, 'dbo.PHIP_date' ), +( 778, 'dbo.Phone_call_log' ), +( 779, 'dbo.Physical_inventory_detail' ), +( 780, 'dbo.Physical_inventory_master' ), +( 781, 'dbo.PJ_item_link' ), +( 782, 'dbo.PJ_pre_cost_entry_link' ), +( 783, 'dbo.PJS_layout_detail' ), +( 784, 'dbo.PJS_layout_detail_text' ), +( 785, 'dbo.PJS_layout_master' ), +( 786, 'dbo.PJS_layout_master_text' ), +( 787, 'dbo.PJS_task_selection' ), +( 788, 'dbo.PJS_totalizator_link' ), +( 789, 'dbo.PKD_DL_link' ), +( 790, 'dbo.Point_of_sale' ), +( 791, 'dbo.PPB_address_selection' ), +( 792, 'dbo.PPB_OU_selection' ), +( 793, 'dbo.PPB_payment_method' ), +( 794, 'dbo.PR_certificate_detail' ), +( 795, 'dbo.PR_certificate_header' ), +( 796, 'dbo.PR_certificate_layout' ), +( 797, 'dbo.PR_certificate_layout_text' ), +( 798, 'dbo.PR_cust_list_column' ), +( 799, 'dbo.PR_cust_list_column_text' ), +( 800, 'dbo.PR_customized_list' ), +( 801, 'dbo.PR_customized_list_text' ), +( 802, 'dbo.PR_global_value_link' ), +( 803, 'dbo.PR_global_value_link_text' ), +( 804, 'dbo.PR_official_list' ), +( 805, 'dbo.PR_official_list_col_text' ), +( 806, 'dbo.PR_official_list_column' ), +( 807, 'dbo.PR_official_list_text' ), +( 808, 'dbo.PR_periodicity_type' ), +( 809, 'dbo.PR_periodicity_type_text' ), +( 810, 'dbo.PRCH_EPP_link' ), +( 811, 'dbo.PRCH_status_history' ), +( 812, 'dbo.Pre_cost_entry' ), +( 813, 'dbo.Pre_cost_entry_master' ), +( 814, 'dbo.Pre_cost_entry_master_text' ), +( 815, 'dbo.Pre_entry_link' ), +( 816, 'dbo.Predefined_entry' ), +( 817, 'dbo.Predefined_entry_flow' ), +( 818, 'dbo.Predefined_entry_print_text' ), +( 819, 'dbo.Predefined_entry_rounding' ), +( 820, 'dbo.Prelim_entry_master_text' ), +( 821, 'dbo.Preliminary_entry' ), +( 822, 'dbo.Preliminary_entry_master' ), +( 823, 'dbo.Premise' ), +( 824, 'dbo.Premise_text' ), +( 825, 'dbo.Prescription' ), +( 826, 'dbo.Prescription_task_link' ), +( 827, 'dbo.PRH_activity_type_link' ), +( 828, 'dbo.PRH_boundary' ), +( 829, 'dbo.PRH_boundary_history' ), +( 830, 'dbo.PRH_boundary_text' ), +( 831, 'dbo.PRH_complement' ), +( 832, 'dbo.PRH_complement_text' ), +( 833, 'dbo.PRH_item_link' ), +( 834, 'dbo.PRH_layout_link' ), +( 835, 'dbo.PRH_list_column_link' ), +( 836, 'dbo.PRH_period_type' ), +( 837, 'dbo.PRH_PRHC_link' ), +( 838, 'dbo.PRH_totalizator_link' ), +( 839, 'dbo.Price_code' ), +( 840, 'dbo.Price_code_text' ), +( 841, 'dbo.Price_element' ), +( 842, 'dbo.Price_element_text' ), +( 843, 'dbo.Price_modifier' ), +( 844, 'dbo.Price_type' ), +( 845, 'dbo.Price_type_text' ), +( 846, 'dbo.Print_style' ), +( 847, 'dbo.Print_style_text' ), +( 848, 'dbo.Pro_svc_psbl_answer' ), +( 849, 'dbo.Pro_svc_psbl_answer_text' ), +( 850, 'dbo.Pro_svc_question' ), +( 851, 'dbo.Pro_svc_question_text' ), +( 852, 'dbo.Pro_svc_received_answer' ), +( 853, 'dbo.Pro_svc_session' ), +( 854, 'dbo.Pro_svc_session_answer' ), +( 855, 'dbo.Process_document' ), +( 856, 'dbo.Process_document_link' ), +( 857, 'dbo.Process_header' ), +( 858, 'dbo.Process_line' ), +( 859, 'dbo.Process_line_antecedence' ), +( 860, 'dbo.Process_line_option' ), +( 861, 'dbo.Process_option' ), +( 862, 'dbo.Process_overlap_header' ), +( 863, 'dbo.Process_overlap_line' ), +( 864, 'dbo.Process_overlap_text' ), +( 865, 'dbo.Process_revision' ), +( 866, 'dbo.Process_sub_contractor' ), +( 867, 'dbo.Product_line' ), +( 868, 'dbo.Product_line_text' ), +( 869, 'dbo.Production_time' ), +( 870, 'dbo.Profit_cost_center' ), +( 871, 'dbo.Profit_cost_center_key' ), +( 872, 'dbo.Profit_cost_center_text' ), +( 873, 'dbo.Profit_cost_type' ), +( 874, 'dbo.Profit_cost_type_key' ), +( 875, 'dbo.Profit_cost_type_text' ), +( 876, 'dbo.Project' ), +( 877, 'dbo.Project_address_link' ), +( 878, 'dbo.Project_criteria' ), +( 879, 'dbo.Project_entry' ), +( 880, 'dbo.Project_key' ), +( 881, 'dbo.Project_resource' ), +( 882, 'dbo.Project_status_history' ), +( 883, 'dbo.Project_structure' ), +( 884, 'dbo.Project_structure_text' ), +( 885, 'dbo.Project_weighting' ), +( 886, 'dbo.PROL_column_link' ), +( 887, 'dbo.Prospection' ), +( 888, 'dbo.Prospection_amount' ), +( 889, 'dbo.Prospection_criteria' ), +( 890, 'dbo.Prospection_reason' ), +( 891, 'dbo.PRPET_conversion' ), +( 892, 'dbo.QRCodes' ), +( 893, 'dbo.Quantity_formula_detail' ), +( 894, 'dbo.Quantity_formula_master' ), +( 895, 'dbo.Quantity_formula_master_txt' ), +( 896, 'dbo.RAFAM_action_monitor' ), +( 897, 'dbo.RAFAM_notification' ), +( 898, 'dbo.Reason' ), +( 899, 'dbo.Reason_text' ), +( 900, 'dbo.Receipt_summary' ), +( 901, 'dbo.REG_status_history' ), +( 902, 'dbo.Registration' ), +( 903, 'dbo.Registration_booth_link' ), +( 904, 'dbo.Religion' ), +( 905, 'dbo.Religion_text' ), +( 906, 'dbo.Remark_type' ), +( 907, 'dbo.Remark_type_text' ), +( 908, 'dbo.Remedy' ), +( 909, 'dbo.Remedy_text' ), +( 910, 'dbo.Reminder_method' ), +( 911, 'dbo.Report' ), +( 912, 'dbo.Repository_update_log' ), +( 913, 'dbo.Room_category' ), +( 914, 'dbo.Room_category_text' ), +( 915, 'dbo.Salary_grade' ), +( 916, 'dbo.Salary_grade_funct_link' ), +( 917, 'dbo.Salary_grade_history' ), +( 918, 'dbo.Salary_grade_text' ), +( 919, 'dbo.Sales_rep_address_list' ), +( 920, 'dbo.Sales_representative' ), +( 921, 'dbo.Sales_tax_code' ), +( 922, 'dbo.Sales_tax_code_text' ), +( 923, 'dbo.Sales_tax_rate' ), +( 924, 'dbo.Sector' ), +( 925, 'dbo.Sector_text' ), +( 926, 'dbo.Security_custody' ), +( 927, 'dbo.Security_group' ), +( 928, 'dbo.Security_group_text' ), +( 929, 'dbo.Serial_number' ), +( 930, 'dbo.Serial_number_history' ), +( 931, 'dbo.Serial_number_status' ), +( 932, 'dbo.Serial_number_status_text' ), +( 933, 'dbo.Shipping_method' ), +( 934, 'dbo.Shipping_method_text' ), +( 935, 'dbo.Signature_schema' ), +( 936, 'dbo.Signature_schema_detail' ), +( 937, 'dbo.Signature_schema_text' ), +( 938, 'dbo.Signboard' ), +( 939, 'dbo.Signboard_contract' ), +( 940, 'dbo.Signboard_DL_link' ), +( 941, 'dbo.Signboard_location' ), +( 942, 'dbo.Signboard_location_hist' ), +( 943, 'dbo.Signboard_per_status_hist' ), +( 944, 'dbo.Signboard_periodicity' ), +( 945, 'dbo.Signboard_type' ), +( 946, 'dbo.Signboard_type_text' ), +( 947, 'dbo.SP_catalog' ), +( 948, 'dbo.SP_catalog_text' ), +( 949, 'dbo.SQL_connection' ), +( 950, 'dbo.SSSI_OU_link' ), +( 951, 'dbo.Standard_cost_param' ), +( 952, 'dbo.Standard_cost_rate' ), +( 953, 'dbo.Standard_text' ), +( 954, 'dbo.Standard_text_text' ), +( 955, 'dbo.Standard_text_type' ), +( 956, 'dbo.Standard_text_type_text' ), +( 957, 'dbo.Standard_unit_conversion' ), +( 958, 'dbo.STASD_event' ), +( 959, 'dbo.Statistic' ), +( 960, 'dbo.Statistic_OU_link' ), +( 961, 'dbo.Status' ), +( 962, 'dbo.Status_schema' ), +( 963, 'dbo.Status_schema_detail' ), +( 964, 'dbo.Status_schema_header' ), +( 965, 'dbo.Status_schema_header_text' ), +( 966, 'dbo.Status_text' ), +( 967, 'dbo.Status_type' ), +( 968, 'dbo.Status_type_text' ), +( 969, 'dbo.Stock_trans_effective_cost' ), +( 970, 'dbo.Stock_trans_type' ), +( 971, 'dbo.Stock_trans_type_text' ), +( 972, 'dbo.Stock_transaction' ), +( 973, 'dbo.Stock_transaction_master' ), +( 974, 'dbo.STT_PD_link' ), +( 975, 'dbo.Sub_contractor_terms' ), +( 976, 'dbo.SUB_RAFAM_parameter' ), +( 977, 'dbo.Subsidiary' ), +( 978, 'dbo.Supplier' ), +( 979, 'dbo.Surplus_header' ), +( 980, 'dbo.Surplus_header_text' ), +( 981, 'dbo.Surplus_line' ), +( 982, 'dbo.Swiss_AVS_structure' ), +( 983, 'dbo.Swiss_bank_clearing' ), +( 984, 'dbo.Swiss_customs_detail' ), +( 985, 'dbo.Swiss_EMCH_supplement' ), +( 986, 'dbo.Swiss_payroll_parameters' ), +( 987, 'dbo.Symptom' ), +( 988, 'dbo.Symptom_text' ), +( 989, 'dbo.sysdiagrams' ), +( 990, 'dbo.System_email' ), +( 991, 'dbo.System_site' ), +( 992, 'dbo.System_site_link_auth' ), +( 993, 'dbo.System_site_SQL_instance' ), +( 994, 'dbo.System_site_SUB_link' ), +( 995, 'dbo.System_site_transfer' ), +( 996, 'dbo.Tariff' ), +( 997, 'dbo.Tariff_type' ), +( 998, 'dbo.Tariff_type_text' ), +( 999, 'dbo.Task' ), +( 1000, 'dbo.Task_address_link' ) + +INSERT INTO @usedTablesArizona ([id], [tblName]) +VALUES +( 1001, 'dbo.Task_budget_detail' ), +( 1002, 'dbo.Task_criteria' ), +( 1003, 'dbo.Task_key' ), +( 1004, 'dbo.Task_progress_history' ), +( 1005, 'dbo.Task_resource' ), +( 1006, 'dbo.Task_status_history' ), +( 1007, 'dbo.TC_authorized_value' ), +( 1008, 'dbo.Tech_criteria_value' ), +( 1009, 'dbo.Tech_criteria_value_text' ), +( 1010, 'dbo.Technical_criteria' ), +( 1011, 'dbo.Technical_criteria_text' ), +( 1012, 'dbo.Telecom' ), +( 1013, 'dbo.Terms_schema_detail' ), +( 1014, 'dbo.Terms_schema_header' ), +( 1015, 'dbo.Terms_schema_header_text' ), +( 1016, 'dbo.Time_period' ), +( 1017, 'dbo.Time_period_master' ), +( 1018, 'dbo.Time_period_master_text' ), +( 1019, 'dbo.Time_period_text' ), +( 1020, 'dbo.Time_sheet_rate' ), +( 1021, 'dbo.Time_sheet_special_rate' ), +( 1022, 'dbo.Time_table_schema' ), +( 1023, 'dbo.Time_table_schema_date' ), +( 1024, 'dbo.Time_table_schema_detail' ), +( 1025, 'dbo.Time_table_schema_history' ), +( 1026, 'dbo.Time_table_schema_text' ), +( 1027, 'dbo.Time_table_type' ), +( 1028, 'dbo.Time_table_type_detail' ), +( 1029, 'dbo.Time_table_type_history' ), +( 1030, 'dbo.Time_table_type_text' ), +( 1031, 'dbo.Title' ), +( 1032, 'dbo.Title_text' ), +( 1033, 'dbo.TK_pre_cost_entry_link' ), +( 1034, 'dbo.Transaction_header' ), +( 1035, 'dbo.Transaction_line' ), +( 1036, 'dbo.TriaScan_Document' ), +( 1037, 'dbo.Unit_code' ), +( 1038, 'dbo.Unit_code_text' ), +( 1039, 'dbo.User_card' ), +( 1040, 'dbo.Variable_price' ), +( 1041, 'dbo.VAT_period' ), +( 1042, 'dbo.VAT_period_text' ), +( 1043, 'dbo.Vehicle' ), +( 1044, 'dbo.Vehicle_text' ), +( 1045, 'dbo.Vendor_managed_inv_text' ), +( 1046, 'dbo.Vendor_managed_inventory' ), +( 1047, 'dbo.VIP_card' ), +( 1048, 'dbo.VIP_card_issue_type' ), +( 1049, 'dbo.VIP_card_type' ), +( 1050, 'dbo.VIP_card_type_link' ), +( 1051, 'dbo.VIP_card_type_text' ), +( 1052, 'dbo.VIP_deny_discount' ), +( 1053, 'dbo.VIPCT_marketing_type' ), +( 1054, 'dbo.Web_service_access' ), +( 1055, 'dbo.Web_service_access_text' ), +( 1056, 'dbo.Weekly_schema_detail' ), +( 1057, 'dbo.Weekly_schema_header' ), +( 1058, 'dbo.WKOP_assignment' ), +( 1059, 'dbo.WKOP_external_reference' ), +( 1060, 'dbo.WKOP_planning' ), +( 1061, 'dbo.WKOP_planning_header' ), +( 1062, 'dbo.WKPA_capacity' ), +( 1063, 'dbo.Work_center' ), +( 1064, 'dbo.Work_center_text' ), +( 1065, 'dbo.Work_location' ), +( 1066, 'dbo.Work_location_text' ), +( 1067, 'dbo.Work_order' ), +( 1068, 'dbo.Work_order_BOM_location' ), +( 1069, 'dbo.Work_order_cost' ), +( 1070, 'dbo.Work_order_process' ), +( 1071, 'dbo.Work_order_process_qty' ), +( 1072, 'dbo.Work_order_status_history' ), +( 1073, 'dbo.Work_permit' ), +( 1074, 'dbo.Work_sheet_header' ), +( 1075, 'dbo.Work_type' ), +( 1076, 'dbo.Work_type_text' ), +( 1077, 'dbo.Workplace' ), +( 1078, 'dbo.Workplace_text' ), +( 1079, 'dbo.WSA_connection' ), +( 1080, 'dbo.Zip_code' ), +( 1081, 'dbo.ZIP_distance_chart' ), +( 1082, 'dbo.ZZ_DVE_MON_TRACKING' ), +( 1083, 'del.CCI_address' ), +( 1084, 'del.CCI_address_key' ), +( 1085, 'del.CCI_ATA' ), +( 1086, 'del.CCI_document_header' ), +( 1087, 'del.CCI_item' ), +( 1088, 'del.CCI_PD_deposit_code' ), +( 1089, 'del.CCI_reminder' ), +( 1090, 'dnz.ItemSearch' ), +( 1091, 'repl.ArticleColumnException' ), +( 1092, 'repl.ArticleConfiguration' ), +( 1093, 'repl.PublicationConfiguration' ), +( 1094, 'upd.Change_tracking_monitor' ), +( 1095, 'upd.IA_IndexAlignementActions' ) + + +SELECT SCHEMA_NAME(t.[schema_id])+'.'+t.[name] AS tableName, + CASE WHEN u.id IS NULL THEN 0 ELSE 1 END AS isUsed +FROM arizona.sys.tables t + LEFT JOIN @usedTablesArizona u ON u.[tblName] = SCHEMA_NAME(t.[schema_id])+'.'+t.[name] +WHERE t.[type_desc] = 'USER_TABLE' --only tables +and SCHEMA_NAME(t.[schema_id]) = 'dbo' +and t.name not like 'TT%' +ORDER BY [isUsed], SCHEMA_NAME(t.[schema_id]), t.[name] + diff --git a/DELPHIX DBG - restore arizona_delphix.sql b/DELPHIX DBG - restore arizona_delphix.sql new file mode 100644 index 0000000..573d308 --- /dev/null +++ b/DELPHIX DBG - restore arizona_delphix.sql @@ -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]; diff --git a/EXPLOIT - change compatibility mode for all db's.sql b/EXPLOIT - change compatibility mode for all db's.sql new file mode 100644 index 0000000..73b3ec5 --- /dev/null +++ b/EXPLOIT - change compatibility mode for all db's.sql @@ -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; diff --git a/EXPLOIT - check last full backup date.sql b/EXPLOIT - check last full backup date.sql new file mode 100644 index 0000000..d61b4d5 --- /dev/null +++ b/EXPLOIT - check last full backup date.sql @@ -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 \ No newline at end of file diff --git a/EXPLOIT - disk usage and db size.sql b/EXPLOIT - disk usage and db size.sql new file mode 100644 index 0000000..789ecf9 --- /dev/null +++ b/EXPLOIT - disk usage and db size.sql @@ -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; \ No newline at end of file diff --git a/EXPLOIT - identity.sql b/EXPLOIT - identity.sql new file mode 100644 index 0000000..26d6ba4 --- /dev/null +++ b/EXPLOIT - identity.sql @@ -0,0 +1,4 @@ +SELECT * +FROM [master].cfg.[Identity] [i] +SELECT * +FROM master.cfg.[InstanceContext] [ic] \ No newline at end of file diff --git a/EXPLOIT - last db full backup.sql b/EXPLOIT - last db full backup.sql new file mode 100644 index 0000000..27be637 --- /dev/null +++ b/EXPLOIT - last db full backup.sql @@ -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' +) diff --git a/EXPLOIT - missing db backup path 2 setting.sql b/EXPLOIT - missing db backup path 2 setting.sql new file mode 100644 index 0000000..21f4948 --- /dev/null +++ b/EXPLOIT - missing db backup path 2 setting.sql @@ -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 diff --git a/EXPLOIT - restart activePosClientService.sql b/EXPLOIT - restart activePosClientService.sql new file mode 100644 index 0000000..cb07239 --- /dev/null +++ b/EXPLOIT - restart activePosClientService.sql @@ -0,0 +1,3 @@ +EXEC xp_cmdshell 'net stop ActiveposClientService'; + +EXEC xp_cmdshell 'net start ActiveposClientService' \ No newline at end of file diff --git a/EXPLOIT - restart all distribution jobs.sql b/EXPLOIT - restart all distribution jobs.sql new file mode 100644 index 0000000..c26154b --- /dev/null +++ b/EXPLOIT - restart all distribution jobs.sql @@ -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 diff --git a/EXPLOIT - start a job if not running.sql b/EXPLOIT - start a job if not running.sql new file mode 100644 index 0000000..90cf7f5 --- /dev/null +++ b/EXPLOIT - start a job if not running.sql @@ -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 \ No newline at end of file diff --git a/EXPLOIT - start replication agents that are stopped.sql b/EXPLOIT - start replication agents that are stopped.sql new file mode 100644 index 0000000..2dc6dec --- /dev/null +++ b/EXPLOIT - start replication agents that are stopped.sql @@ -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 \ No newline at end of file diff --git a/EXPLOIT - start replication.sql b/EXPLOIT - start replication.sql new file mode 100644 index 0000000..74b5373 --- /dev/null +++ b/EXPLOIT - start replication.sql @@ -0,0 +1 @@ +exec msdb.dbo.sp_start_job @job_name='D00480 - ActivePos_read Snapshot' \ No newline at end of file diff --git a/EXPLOIT - syncro h gcmtestcent.sql b/EXPLOIT - syncro h gcmtestcent.sql new file mode 100644 index 0000000..d1dad83 --- /dev/null +++ b/EXPLOIT - syncro h gcmtestcent.sql @@ -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 diff --git a/GAIA - delete data from short aliases.sql b/GAIA - delete data from short aliases.sql new file mode 100644 index 0000000..1b25388 --- /dev/null +++ b/GAIA - delete data from short aliases.sql @@ -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 + + diff --git a/HCI - BAG - sl2007_to_onprem publication.sql b/HCI - BAG - sl2007_to_onprem publication.sql new file mode 100644 index 0000000..b866cf3 --- /dev/null +++ b/HCI - BAG - sl2007_to_onprem publication.sql @@ -0,0 +1,1230 @@ +-- 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_to_onprem', @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_to_onprem', @frequency_type = 4, @frequency_interval = 1, @frequency_relative_interval = 0, @frequency_recurrence_factor = 0, @frequency_subday = 1, @frequency_subday_interval = 0, @active_start_time_of_day = 213046, @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_to_onprem', @login = N'sa' +GO +exec sp_grant_publication_access @publication = N'sl2007_to_onprem', @login = N'sql-repl_agent' +GO +exec sp_grant_publication_access @publication = N'sl2007_to_onprem', @login = N'Sec-SQL-RL_DBAOps' +GO +exec sp_grant_publication_access @publication = N'sl2007_to_onprem', @login = N'distributor_admin' +GO +exec sp_grant_publication_access @publication = N'sl2007_to_onprem', @login = N'superuser' +GO + +-- Adding the snapshot articles +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'Allergene_20120817_Streichungen', @source_owner = N'dbo', @source_object = N'Allergene_20120817_Streichungen', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'Allergene_20120817_Streichungen', @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_to_onprem', @article = N'Allergene20110901', @source_owner = N'dbo', @source_object = N'Allergene20110901', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'Allergene20110901', @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_to_onprem', @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_to_onprem', @article = N'ATCDESCR', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'CHARACTERISTIC_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'ATCDESCR', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ATCDESCR', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'ATCDESCR', @view_name = N'syncobj_0x3135314533353739', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'CURRENCY', @source_owner = N'dbo', @source_object = N'CURRENCY', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'CURRENCY', @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_to_onprem', @article = N'CURRENCY', @column = N'CDCURRENCY', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'CURRENCY', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'CURRENCY', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'CURRENCY', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'CURRENCY', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'CURRENCY', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'CURRENCY', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'CURRENCY', @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_to_onprem', @article = N'CURRENCY', @view_name = N'syncobj_0x3135444335333035', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'Deutsch$', @source_owner = N'dbo', @source_object = N'Deutsch$', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'Deutsch$', @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_to_onprem', @article = N'DUE_GROUP', @source_owner = N'dbo', @source_object = N'DUE_GROUP', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'DUE_GROUP', @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_to_onprem', @article = N'DUE_GROUP', @column = N'DUE_GROUPNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_GROUP', @column = N'DUE_USERID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_GROUP', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_GROUP', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_GROUP', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_GROUP', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_GROUP', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_GROUP', @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_to_onprem', @article = N'DUE_GROUP', @view_name = N'syncobj_0x3935464243373241', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @source_owner = N'dbo', @source_object = N'DUE_USER', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'DUE_USER', @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_to_onprem', @article = N'DUE_USER', @column = N'DUE_USERID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'EMAIL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'PASSWORT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'DUE_USER', @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_to_onprem', @article = N'DUE_USER', @view_name = N'syncobj_0x4335353134443137', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @source_owner = N'dbo', @source_object = N'FOREIGNPRICE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'FOREIGNPRICE', @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_to_onprem', @article = N'FOREIGNPRICE', @column = N'FOREIGNPRICENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'CDPRICETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'DATEINFORCE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'CDCURRENCY', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'PRICE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICE', @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_to_onprem', @article = N'FOREIGNPRICE', @view_name = N'syncobj_0x4242433541314238', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @source_owner = N'dbo', @source_object = N'FOREIGNPRICECOMP', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'FOREIGNPRICECOMP', @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_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'PRICECOMPLINENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'PRICECOMPNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'CDCURRENCY', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'PEXF_CH_ALT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'PEXF_CNTRY', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'PEXF_CNTRY_PACKCALC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'CURRENCYCHANGE100CHF', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'PEXF_CNTRY_CHF', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'DESCR_CNTRY', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP', @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_to_onprem', @article = N'FOREIGNPRICECOMP', @view_name = N'syncobj_0x3133374344444442', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @source_owner = N'dbo', @source_object = N'FOREIGNPRICECOMP_RESULT', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'FOREIGNPRICECOMP_RESULT', @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_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'PRICECOMPNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'PRICECOMP_DATE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'AVGPEXF_FOREIGN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'PERCENTCHANGE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'PEXFNEW_CH', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'PPUBNEW_CH', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @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_to_onprem', @article = N'FOREIGNPRICECOMP_RESULT', @view_name = N'syncobj_0x3731434537394539', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'GalFormTrans', @source_owner = N'dbo', @source_object = N'GalFormTrans', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'GalFormTrans', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'GenericGroupCalcMan', @source_owner = N'dbo', @source_object = N'GenericGroupCalcMan', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'GenericGroupCalcMan', @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_to_onprem', @article = N'GenericTab_Diff_SB_ModalPack_Except', @source_owner = N'dbo', @source_object = N'GenericTab_Diff_SB_ModalPack_Except', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'GenericTab_Diff_SB_ModalPack_Except', @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_to_onprem', @article = N'GenericTab_tempMovicol', @source_owner = N'dbo', @source_object = N'GenericTab_tempMovicol', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'GenericTab_tempMovicol', @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_to_onprem', @article = N'Grenzwert_DiffSB_Biologika', @source_owner = N'dbo', @source_object = N'Grenzwert_DiffSB_Biologika', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'Grenzwert_DiffSB_Biologika', @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_to_onprem', @article = N'IMPORT$', @source_owner = N'dbo', @source_object = N'IMPORT$', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'IMPORT$', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'ITDESCR', @column = N'CDIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'ITCOMMENT_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'ITCOMMENT_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'ITCOMMENT_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'UeberpruefungseinheitCode', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITDESCR', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'ITDESCR', @view_name = N'syncobj_0x4242463343344236', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'ITLIMIT', @column = N'CDITLIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'CDIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'ITLIMIT', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'ITLIMIT', @view_name = N'syncobj_0x3939464131434442', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'LIMITATION', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'LimitationChangeType_FK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'CDLIMIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'LIMITTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'LIMITNIVEAU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'LIMITVALUE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LIMITATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'LIMITATION', @view_name = N'syncobj_0x4430383945453535', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'LimitationChangeType', @column = N'LimitationChangeType_PK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'Code', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'Sort', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'Descr_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'Descr_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'DbStatus', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'DbInsDatim', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'DbInsUser', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'DbUpdDatim', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'LimitationChangeType', @column = N'DbUpdUser', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'LimitationChangeType', @view_name = N'syncobj_0x3533323730463537', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'Logging', @source_owner = N'dbo', @source_object = N'Logging', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'Logging', @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_to_onprem', @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_to_onprem', @article = N'NATION', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'NATION', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'NATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'NATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'NATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'NATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'NATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'NATION', @view_name = N'syncobj_0x3231394344384133', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PACK', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'VertriebsanteilGruppeId', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'PACKNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PACK', @column = N'SWISSMEDIC_CAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'BAGDOSSIERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'GTIN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'SIZEPACK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'PREV_GTINCODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'SWISSMEDICNR8_PARALLELIMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK', @view_name = N'syncobj_0x3742353639323035', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_IGNORE', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_IGNORE', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PACK_IGNORE', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'BAGDOSSIERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_IGNORE', @view_name = N'syncobj_0x4532413146303333', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PACK_LIMPTS', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_LIMPTS', @column = N'LIMPOINTS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_LIMPTS', @column = N'LIMPACKS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PACK_LIMPTS', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_LIMPTS', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_LIMPTS', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_LIMPTS', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_LIMPTS', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_LIMPTS', @view_name = N'syncobj_0x4146433232314537', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_MUTATION', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_MUTATION', @column = N'PACKNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PACK_MUTATION', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'BAGDOSSIERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_MUTATION', @view_name = N'syncobj_0x3841413031353745', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_NEW', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PACK_NEW', @column = N'SWISSMEDICNR8', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'FLAGNARC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'FLAGMODAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'LIFECYCLE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACK_NEW', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACK_NEW', @view_name = N'syncobj_0x3541464430393445', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPARTNER', @column = N'PACKPARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'PARTNERTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPARTNER', @view_name = N'syncobj_0x3235444444463343', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'PACKPARTNERIGNORENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPARTNER_IGNORE', @view_name = N'syncobj_0x3839414336333242', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'PACKPARTNERMUTATIONNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'PARTNERTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPARTNER_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPARTNER_MUTATION', @view_name = N'syncobj_0x3341453136344631', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPRICE', @column = N'PRICENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'CDPRICETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'PRICE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DIVISION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DIVPRICEINCVAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DIVISIONDESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'CDPRICECHANGETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PACKPRICE', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PACKPRICE', @view_name = N'syncobj_0x3041463945453136', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'PACKPRICE_IMPORT', @source_owner = N'dbo', @source_object = N'PACKPRICE_IMPORT', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PACKPRICE_IMPORT', @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_to_onprem', @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_to_onprem', @article = N'PARTNER', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'PARTNERNRALT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'PARTNERNO_EMEDIAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PARTNER', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'NAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'ADDNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'STREET', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'PLZ', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'PLACE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'KANTON', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'EAN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'VATNR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'EMAIL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'INTERNET', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'CONTACT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'PHONE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'FAXNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PARTNER', @view_name = N'syncobj_0x3132364531314438', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PARTNER_IGNORE', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PARTNER_IGNORE', @column = N'COMPANYNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_IGNORE', @column = N'ADDNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PARTNER_IGNORE', @view_name = N'syncobj_0x3444363044453641', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PARTNER_MUTATION', @column = N'PARTNERNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PARTNER_MUTATION', @column = N'COMPANYNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_MUTATION', @column = N'ADDNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PARTNER_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PARTNER_MUTATION', @view_name = N'syncobj_0x4243373035354337', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'PREPARNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'NAME_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'NAME_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'NAME_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'COMMENT_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'COMMENT_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'COMMENT_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'PREPNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'PREPNAMENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'PREPNAMENO_BOOK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'LOASPEZ', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'COM_FlagAPV', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPARATION', @view_name = N'syncobj_0x3437384346383244', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_IGNORE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_IGNORE', @view_name = N'syncobj_0x3837423244463130', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'PREPARNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_MUTATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_MUTATION', @view_name = N'syncobj_0x3145424444464344', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_NAME_save_vorGammendef20120404', @source_owner = N'dbo', @source_object = N'PREPARATION_NAME_save_vorGammendef20120404', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PREPARATION_NAME_save_vorGammendef20120404', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPARATION_NEW', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_NEW', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_NEW', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_NEW', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_NEW', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_NEW', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_NEW', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPARATION_NEW', @view_name = N'syncobj_0x4131353039413144', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @source_owner = N'dbo', @source_object = N'PREPARATION_SAVE', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPARATION_SAVE', @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_to_onprem', @article = N'PREPARATION_SAVE', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'PREPARNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'NAME_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'NAME_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'NAME_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'NAME_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'NAME_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'NAME_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'COMMENT_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'COMMENT_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'COMMENT_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'PREPNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'PREPNAMENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'LOASPEZ', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'COM_FlagAPV', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_SAVE', @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_to_onprem', @article = N'PREPARATION_SAVE', @view_name = N'syncobj_0x3634373745334533', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @source_owner = N'dbo', @source_object = N'PREPARATION_Temp', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'PREPARATION_Temp', @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_to_onprem', @article = N'PREPARATION_Temp', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'PREPARNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'NAME_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'NAME_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'NAME_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'NAME_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'NAME_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'NAME_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DESCR_DE_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DESCR_FR_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DESCR_IT_ORIGINAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'CDATC', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'SWISSMEDICNR5', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'ITLIMVALID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'CDORGGEN', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'FLAGSB20', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'CDNATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'COMMENT_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'COMMENT_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'COMMENT_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'PREPNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'PREPNAMENO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @column = N'LOASPEZ', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 + +-- Adding the article synchronization object +exec sp_articleview @publication = N'sl2007_to_onprem', @article = N'PREPARATION_Temp', @view_name = N'syncobj_0x3744354530443341', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @article = N'PREPARATIONNAME_BAGEMAIL', @source_owner = N'dbo', @source_object = N'PREPARATIONNAME_BAGEMAIL', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'PREPARATIONNAME_BAGEMAIL', @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_to_onprem', @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_to_onprem', @article = N'PREPARATIONTASK', @column = N'PREPARATIONTASKNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'COMPLETED', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DUE_DATE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DUE_USERID', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DUE_GROUPNAME', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPARATIONTASK', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPARATIONTASK', @view_name = N'syncobj_0x3831323836314132', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPIT', @column = N'PREPITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPIT', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPIT', @column = N'CDIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPIT', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPIT', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPIT', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPIT', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPIT', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPIT', @view_name = N'syncobj_0x4431383839424130', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKLIMIT', @column = N'PREPLIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKLIMIT', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKLIMIT', @view_name = N'syncobj_0x3832363239423245', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'PREPLIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'LIMITNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKLIMIT_GGML', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKLIMIT_GGML', @view_name = N'syncobj_0x4431333339333543', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKSTATUS', @column = N'PREPPACKSTATUSNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DATEINTEGRAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DATEVALID_THRU', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'CDSTATUSTYPESL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'FLAGAPD', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKSTATUS', @view_name = N'syncobj_0x4439384233433039', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'PREPPACKSTATUSNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'PHARMACODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'DATEINTEGRAT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'CDSTATUSTYPEGGML', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'FLAGAPD', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPPACKSTATUS_GGML', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPPACKSTATUS_GGML', @view_name = N'syncobj_0x3841303434304139', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPSUB', @column = N'PREPSUBNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'PRODUCT_COMMERCIAL', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'CH_NUMBER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'CDWHK', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'LNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'QUANTITY', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'QUANTITY_UNIT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PREPSUB', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PREPSUB', @view_name = N'syncobj_0x4643343737323842', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PRICECHANGETYPE', @column = N'CDPRICECHANGETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICECHANGETYPE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PRICECHANGETYPE', @view_name = N'syncobj_0x3439333933373232', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PRICETYPE', @column = N'CDPRICETYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PRICETYPE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PRICETYPE', @view_name = N'syncobj_0x4533393542334344', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PUBLICATION', @column = N'PUBLICATIONNO', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'DATEVALID_FROM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'CDPUBLICATIONSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'BagBulletinFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'BagBulletinTextFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'ITCodesFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'GenericsFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'GenericListDiffSBFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'GeburtsGebrechenMedikamentListFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'PreparationsFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'PublicationsToExcelFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'DeletedPackagesFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'HistoryFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'TIME_STAMP', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION', @column = N'GeburtsGebrechenSpezListFileName', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PUBLICATION', @view_name = N'syncobj_0x4246463041344145', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PUBLICATION_STATUS', @column = N'CDPUBLICATIONSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION_STATUS', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION_STATUS', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION_STATUS', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION_STATUS', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION_STATUS', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'PUBLICATION_STATUS', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'PUBLICATION_STATUS', @view_name = N'syncobj_0x4632354235313733', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'STATUSTYPE_GGML', @column = N'CDSTATUSTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_GGML', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_GGML', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_GGML', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_GGML', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_GGML', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_GGML', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'STATUSTYPE_GGML', @view_name = N'syncobj_0x3537364132393144', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'STATUSTYPE_SL', @column = N'CDSTATUSTYPE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_SL', @column = N'DESCR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_SL', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_SL', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_SL', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_SL', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'STATUSTYPE_SL', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'STATUSTYPE_SL', @view_name = N'syncobj_0x3135323733454339', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'SUBSTANCE', @column = N'CH_NUMBER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'SUBSTANCE', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'SUBSTANCE', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'SUBSTANCE', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'SUBSTANCE', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'SUBSTANCE', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'SUBSTANCE', @view_name = N'syncobj_0x3436354245323246', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'Umsatz2014', @source_owner = N'dbo', @source_object = N'Umsatz2014', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'Umsatz2014', @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_to_onprem', @article = N'Umsatz2015', @source_owner = N'dbo', @source_object = N'Umsatz2015', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'Umsatz2015', @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_to_onprem', @article = N'Umsatz2016', @source_owner = N'dbo', @source_object = N'Umsatz2016', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'none', @destination_table = N'Umsatz2016', @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_to_onprem', @article = N'UmsatzImsImport', @source_owner = N'dbo', @source_object = N'UmsatzImsImport', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'UmsatzImsImport', @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_to_onprem', @article = N'UmsatzPreparationName', @source_owner = N'dbo', @source_object = N'UmsatzPreparationName', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'UmsatzPreparationName', @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_to_onprem', @article = N'UmsatzPreparationName_2024_07_08', @source_owner = N'dbo', @source_object = N'UmsatzPreparationName_2024_07_08', @type = N'logbased', @description = N'', @creation_script = N'', @pre_creation_cmd = N'drop', @schema_option = 0x000000000803509D, @identityrangemanagementoption = N'manual', @destination_table = N'UmsatzPreparationName_2024_07_08', @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_to_onprem', @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_to_onprem', @article = N'VARIA', @column = N'PHARMAGRUPPENCODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'IT_CODE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DESCR_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DESCR_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DESCR_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'SIZEPACK_DE', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'SIZEPACK_FR', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'SIZEPACK_IT', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @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_to_onprem', @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_to_onprem', @article = N'VARIA', @column = N'LIMITATION', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'TableNr', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'Sort', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DBSTATUS', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DBINSDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DBINSUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DBUPDDATIM', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @article = N'VARIA', @column = N'DBUPDUSER', @operation = N'add', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +exec sp_articlecolumn @publication = N'sl2007_to_onprem', @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_to_onprem', @article = N'VARIA', @view_name = N'syncobj_0x3938314539384233', @filter_clause = N'', @force_invalidate_snapshot = 1, @force_reinit_subscription = 1 +GO +use [SL2007] +exec sp_addarticle @publication = N'sl2007_to_onprem', @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 + +-- Adding the snapshot subscriptions +use [SL2007] +--exec sp_addsubscription @publication = N'sl2007_to_onprem', @subscriber = N'SWMDATASQLPRD01', @destination_db = N'SL2007_azure', @subscription_type = N'Pull', @sync_type = N'automatic', @article = N'all', @update_mode = N'read only', @subscriber_type = 0 +GO + diff --git a/Query buffer descriptors to determine objects causing latch contention.sql b/Query buffer descriptors to determine objects causing latch contention.sql new file mode 100644 index 0000000..52a46b9 --- /dev/null +++ b/Query buffer descriptors to determine objects causing latch contention.sql @@ -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; \ No newline at end of file diff --git a/REPO - get auth.sql b/REPO - get auth.sql new file mode 100644 index 0000000000000000000000000000000000000000..dd227a5891bce4d0186226f95413e2ef27ad0cc9 GIT binary patch literal 5922 zcmd6rSx;L>6vyYeQoqCP6HY{-WN8vABrF0^qy%UPPgP|(UZ`6y#CDRlAHMDXH^+y$ zW9|i;@(^9!ea`kj%bb~i|2Yq5;V=~8m(UE;FbIE#Nf?KAc&D$Y;n(nO_$IsxC-J@= z9+r+mUq6K3Loal~JnV``AzpLQPxY-U>ZzVP@%dByhLo;oCgQuL=XSUZv(OU%p6FWA z;FIpZMGk1v*4sdDWBq#>-`b)?j>+mojW0E-Sp4rrJ$Ax#@&6&b(Djk-kHS-p*wJ-Y z=M!C@=&dN(@-S>i3&G;O{xrj}Y1d?U9Z$HO~hT=Vqj33?rM81}~mZbv@B2IG@L{_k$s_9mo3nzR(BzoBZ-h zdSP)P-;Fi?qwYQ3ySk2}|N46C$x}tx(>d1vp^nXnMZIkQ<2oG0s2E8bIE)lU#uE+k zf0;MdHKWIPB5L=(%A>f#;GL}LDDtt%?uBxr9Z@rT`7@E76Iq}B8S-E~)7Ngym9gIZ zeM6&pFT{)7A~y#bn=)%F>frJ4KKv!QP7U2$6m8MW^>w5Zv}ZBPpmDm>sB1fpfWkQJ zUj4_L?#b1n34dNlXCev9&}A4lYV9bN@at8|u8Sg%HoJQ)VXvWX^7|3Lk+d2{OtACr zx;b_S5wGMCD(PcYEh^Zvczv!f+dBJ_Ytdrb6vCPj>qcs5|v|Qcdyi5b)nmkPn+s{&s1d#b(Z5; z^@fs;Kg#ivM-=k$=6B-Ym|Um|)AJP4AMNl$ORItx`ob8x8MyMyNu6ev9mLrN8ssq_ zeAZK2_jy)(Jr=K5Rp;RmQ>JWa9e^hFy{!Az(68t2QJ!=6ugF+lMXl4V=URY|4&?1S*rRg6?& zQ14HxFaOVK=Ux{#H`(b{I*)wyWRxEH)%CXSD{KAod`HByZ!i?Lbu{(gJ(KdPV*3Ma zd2LG`x4i=1>h=iS^VJn6=SGETYVF$6`ue=4M%7V_WGAy5vD(seSBG^Fv&waC9iRDP zwY8qU{mSaG9uK-y))JlYhb*9PrOH(G6SiNoB`Xd8z9`d<&D#u#W`;y#LF4{Qi04!} zepLP24$x<&IFN*)v~Q`F)_Y{*4tCvCU*0TawG=_j2XjRvHRZaOSL^%m+)kYBuG@7} zw6g{!3Rx8;J<{ygS4>WX488Dexx@YdV~|&bFUnX@nT z>wp1qPRhGzKD#GoR!1jfbZR^z$lkZkr4|jjodQHaK z{tdSFWvh?P>vxrPDa)$sMA;^usar%ay<0=GqW5H2d-wUFhS}g81`o*{=*I7q{t7-4pkRJ9bmI>wa}_ySLmo?v6ix;NFY2 z26y+|Z|>0TyK{FP&<(Jh1M(F24%}TFkMWG>7ycgc9{}bUc-L^g>rUL6n*i!1sO{tI zTm0_&{TP@I-7{R@!|@R?9AW%9cq3;MH^%-U&UtnX_(}drc(ad+q}-H+8dvC!1~?ypBP0+dXjKW4n*Lcie4k zv7R*k2aLJ{$XnopeBQ*_Hm=7QKgRjJEc7Pu5{6IjVt>bd?J+#Sx!LI7(jjG#9?QoK z*nk!|gZ61xT9{WCuMeQXR_B!ZQ9S^)GuUl~Umf_@wLAbqCsnqdan_xI1d4|3FAYh1q! zByO0I&OqsOrc2%5K_r~aI3Onto}Ys16C9c04!xDme2$8xV+7K2jG9_W8F#USjT`ys z6JM4+sfi6nA zEGmtsn5l8vg*omBHlhwrV22@F%w-#X12j&t(XZRj`d!yhc?Kz%Uxsg{#eLLW#?A;? z>?3TKP*>yp6yuL=KwBUAn6n^K0AZmgN!oBC{R)7|ybW$3Cl8-^!kg*r8b=reBjwmea1!6{P(H z-mbaFXs(HF9IL3wWpAdJH0a-mS#@6&x~qpQoBH4eVxhZ-Psi(u(p{OwobK6iXx1`} z-O&(7hRz#wDmFU{^5Iy9V=wlki}N!J>Dbei>q|h6uS-Dc!GJwXMP0rbTF^qiZ<%V ztf$oq%C$bnnd)r?J@ub{U4!-rYbKYWhil-3Yd^UTtsNotp0)zL2R+vJ#N?%h6Gcb2 zztjG0PHG@)x#+G|A!-)6=!P`kpdMuJSeMj4Qm7I<`jXT>aQnz`q2|+-CWs--=XMgym>Z4;JCn z?F5psGrxe0(}<@boY)Gm@ne*S=w}LjGe;ex_D{UU$l6o7g5x4Y#MozCC$pJOg6hD*Q#dg#Vklnf=esfE$H8B zM~EkOuk<6%Dj5r3!CISc3%?1jZea~;2N5(hvQ!iM#X?;9C{1_uSsb-O1s5 z)%o`OkSFFz?}BzAm*wm}Q9^GjOT<_?hty$Bz@jzKvUfJ*!B!2raK(BIy~_lC+|5G? z?mi$Vh=n0E1v{B_j~DRHA$Zue9l582V9CRecndj%?rprw90s>F2<|!bv)2o?nO2@p@H)hx&1sc!2=RXFP z5pdbM+dllk-T=j%GM{iAJ%(SKy^~k;SPfo$Cr>{0PW~n^u*SqWU@f_dwP4wyEq#z( zlr7R5R9fEYCl4W*BX*$wMT;4?L1!kjEG+uVIh;VN*3A*-DKs#Y*QYaXSqntpxRfN8 z%ksLTpK>N=8jEr1eWc;CIb7-iCCFSwGAwBaRx{^mYts5T&I4FM*$tbNl021iu|`vZ z%dqWzd@aFMIbyQeLt2mHC-hgF3HR$M=+)%^0-1m~*zb(yoqt;8-_$y)z9AfQUX{ys zvWVsN0I#!B42Alsk>OZ^QT^*nOK^*IGtksoiFR5uH98ziaA~~^<8@Yo3$;=s!?6sb zIvK|5tOOI+NR180Hq^gYA4RiIZ4^wX41FUv$hRyrix!XnXGIhrL1sl@T{RSZkVBFF zs+CZf7dh)&1%)Z)F|JxcW_A^lpj`n2o>C3VRlns>uektiG~y ziRU8HhV^eh;j1)$S=jiw_6{l_uhX@to%xstz;qL{aDHRRFN^HkM%J^S2Rmz1Wd=8X z+T8L<4#TSNxnj&cG%Xj0AN7m6$70Bb&(>h$L40&97T8E3(B9DhpYH@58 zacouMuxgU$#GcjhQtHUtp0+rS_(KG2`!8gL?mIu|1F6YFywDh7noL$+ijkU&;KKFD<+vc*R`D{A(rFFaBumxOP zo#t%S-nNA|Z8lryR}p**!T0F9IP#0oxL1zxYFWP0pf{$c{E#z8l$hM z{db5~ZHcFi&-jw3FJ|8E@oDz$9;>(r8LDo497naVilo}{ily4|X-4jrBhAX)W80az zd-P&Vg^Wzd|6(1cOJnq=_B)BL@gdsMUVoXFmEdYTZW(N?_m%L}cwz~*#w$y(%RICU z7xxg0{#Sxq?zwHqp*?_j>bq(pxG+~|r&G^GS`E6_wA-2X|6V;=lwFy=eg#E1D4WTn z_#)_7fUEC{%5uopxvCPnCraJ@#y)(v#<6LgSn1hetN;VQ zXWPKW?;)Q1uV*g&n+0|;{8`6leOkY-Rrqhz@V^&+3386!jQ '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 '%%' + 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 ''%%'' + 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: \ No newline at end of file diff --git a/amr not treated count.sql b/amr not treated count.sql new file mode 100644 index 0000000..9000141 --- /dev/null +++ b/amr not treated count.sql @@ -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 diff --git a/bag mi create publication sl2007.sql b/bag mi create publication sl2007.sql new file mode 100644 index 0000000..7f902f8 --- /dev/null +++ b/bag mi create publication sl2007.sql @@ -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'; \ No newline at end of file diff --git a/bag mi drop publication.sql b/bag mi drop publication.sql new file mode 100644 index 0000000..41dbdaa --- /dev/null +++ b/bag mi drop publication.sql @@ -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 \ No newline at end of file diff --git a/central index correction.sql b/central index correction.sql new file mode 100644 index 0000000..7847eb0 --- /dev/null +++ b/central index correction.sql @@ -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) diff --git a/check gaia publication.sql b/check gaia publication.sql new file mode 100644 index 0000000..5f30b2a --- /dev/null +++ b/check gaia publication.sql @@ -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] \ No newline at end of file diff --git a/check restore history.sql b/check restore history.sql new file mode 100644 index 0000000..8a29200 --- /dev/null +++ b/check restore history.sql @@ -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 \ No newline at end of file diff --git a/craft xml replication monitor.sql b/craft xml replication monitor.sql new file mode 100644 index 0000000..f08f9e6 --- /dev/null +++ b/craft xml replication monitor.sql @@ -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 + + + + + + + + + + + + + + + +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)=' + + @srv@\@inst@ + @srv@\@inst@ + 5 + True + False + False + Snapshot Agent + 0 + 0 + 0 + + +' +DECLARE @tplDis VARCHAR(MAX)=' + + 5 + True + False + Snapshot Agent + 0 + -1 + 0 + + +' +/****** 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 \ No newline at end of file diff --git a/deadlock analysis from extended event ring buffer.sql b/deadlock analysis from extended event ring buffer.sql new file mode 100644 index 0000000..8cf0b2a --- /dev/null +++ b/deadlock analysis from extended event ring buffer.sql @@ -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'); \ No newline at end of file diff --git a/deadlock extended events to ring buffer.sql b/deadlock extended events to ring buffer.sql new file mode 100644 index 0000000..8337280 --- /dev/null +++ b/deadlock extended events to ring buffer.sql @@ -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; \ No newline at end of file diff --git a/drop publication.sql b/drop publication.sql new file mode 100644 index 0000000..d6e1a2e --- /dev/null +++ b/drop publication.sql @@ -0,0 +1,7 @@ +USE < **Publication database name** > +GO +EXEC sp_droppublication @publication = N'' + +USE master +GO +exec sp_replicationdboption @dbname = N'', @optname = N'publish', @value = N'false' \ No newline at end of file diff --git a/dump.sql b/dump.sql new file mode 100644 index 0000000..f42b07b --- /dev/null +++ b/dump.sql @@ -0,0 +1 @@ +EXEC [HCITools].dbo.[bkp_Dump] @in_Recovery_Model = 'FULL,SIMPLE'; \ No newline at end of file diff --git a/hcitools.dbo.Replication_Check.sql b/hcitools.dbo.Replication_Check.sql new file mode 100644 index 0000000000000000000000000000000000000000..fb02b850647b5fdd3bc80c668fa57dcfef40eb3a GIT binary patch literal 164152 zcmeI5>5>#jvZ(7X*X+DQ-6I?8MhhbrNwaCJ5g>^X+t7`4#<*A;G>bTbhM^lI&C|}$ zqnEh%`WIe~M?^;CQdQZ_lGX-Um6aLc;o;%od;Guuduz5myEL26ZqL4*U6@^-?aZFZ z-;>$F?9S{zX8&vU&Fp%({(kmh^f#Bg_h$b+dobIZ9nStF@6V;3LwWOs+`B)!A=hW} z8=qf>d-QN$-gzeNo|4Zu<+tb3&trM&uDtnJe%YVx3JgDnR)3P`XjNO@lQtg9^M~^N zVtD>R==JpMb7}3<**W?Dj9kyir@36ekYCTq^-r_Y@;8ql|8VyEFdjy|Bfp%VT@%PJ zOV8J4w`N!5Z(HtOmv8at?diYEGuP$4O9I8Nyme7NU6b#ZXJ5;|OERkFyR>s&+T|^N zzajr$mvPd@E%~h2ABr1VHT=}CTY@#PdS7sQPiEp#c!zsn@=N)*FL$5F-^XFR^_J`x zYtiRvXZEYi%mZobVD?nzhSuU9J{{clrO?h}X{XtyVsra7O@1k(cr*Wi)Mn|@?3V(y z&%^4N%Urw=ygiod0~z^)#q6+>z~*DYE7*N5-(JY|iCkH2H(s~?$!v^2gPobbAP^h| z__Sx{<$*v075!WOy_)?NR_H^4miu#|s(tyNvGC+mp}r?_WyCs`XA2rRkbAni;Q{}Y z_a4X_v=85~(Y}!Oo7^JC@P)uXz~CSi?ZtfD7*^p^{IUSME;feA(%IQ7?1WwpoP1ETA&{KHwa6kvfqH- zR&dM{;NbfKgUp=c?6=pg#&0@IzV>N>vA|Q}kK`SwCS59#CFqK_*AC$w*P)iFL> z+~b?k)m<4Cd;ES_8~m~v`22oY_2A%8-a0u5iq95M7n zL(m8K|FmcUbCLGvBAZ`XjM3h{D(!;pe5SOO)3P_CReVus1!{$=*xz(kjn_cKj7!(8 z&p6|LC3n$?;C?RSfjwVkNG|A8x^uGbY{i)@bZz!g&}LZ2rbk>17&##{z~4M*K&BC$ z7HlX6Zpxl~K|ZIj!>@Fgwy`Wnp~!i(@HEUUvj>GKmKcX|TKI@+gvbQUMGW`pfNlNX z;6}>5BrT+HBiDh)x=cZz8$w|@zpL+lK3~j;@;9)t`C4j&cAGLNI|zC&a-UK(PrVG7 zV0NF#XI&-0%h~};XkChV-S1*Nd>UxaG+LcM!-G>jt)U&56#h_P0N3n4tUlGn=?R^$ z2K!xE0l>kVSA!m`cmVEaqSx8#P3P*gNUzY?XYxN>H9tM59=RjlrQgx@8C;! zJaEUFHm*_Qh~K3JhhC}>m6 zEO%6&teqkg({#(#(6{DI*|WMlKLI#QOC<{{Vd;*veBM( zHRibgRK{T(yK79){Mj(>o6;sU0yMhgn)Hy%7|c9${)=4WmB2io7AskKZRy%J4BOgD zF?>$;mruhUlTt!F^A`nT*2LLBF=)D92^8S-Wmua{tnLO~_^!;^@{oNd<2o1Sz7AP! z6`{Ys5R9?@bTy$h_TvG_9Ly!F>5Tj-eHss7{XkEwP^cSA0MeIp$aKV5Gm&GU4{vQp z*5UCLuytO3>j53=$znxp z&;Bk_A3H8oj&7imH&!%OqU(ac%5O-dNLk?O=dj}8x6F~RTOiRkYm`F^_oN-SRvRw_ zt58%wJShEO&1T*W54Hx&c=&_xI>UqWg?J^Jgup!R%gjHMkutBjj+*MHJga*UxT%f2 zBy|iMD}0?DROh^Hte?vs^m!O-y0&Yuxen;q=m%TsT{yRZEna`R_IAXAcTVt+RRB74 z{A=Iy*?)>Ox(X-!Pigs~U?1JlXT!(CJlgzPpR8%tgvl8yVdyS_ErxZiJoe4Bp97V7 zYnU(d!CVVm@484IcwW@s^5?L!cnUvN$pYHE2lqwa!s>?o9j*X>bWPw@_~o(uuh;_1 z&34Ln401d~7lQt&o}R76tRMv+1`dmaTK-dBT=vXtNvmcV{+qykuhIrBx3{w`a4>q+ zQ_7I&-S&2FhF0JbU4QNEU=?BqJ`Db~wzk^aQK^zufwqXuS^HxzIIMW7u(%-UvG&^9 zpzZc{*nfZo*$|ny{-=`SuO0K|?foPz)?0&LfT{lN0U`Q)?XO>ZDn}uIsGd`6tuK66 z1ZxK}53d%|cfGv>8S8=cs{WDg^eJsp5MnZ z1owfHb5)D@FD-3fmHu5n@|K#PhPJGl_6xyXv#s>b(3VZhzP6Z=w6*wK-ZDP?Hcaap ze<~PJ&vx8a`Z;e|wb=R`Do^c(7#mbNgJ?T#FvmWZ6vq79(3Z~&1wo_gZOU7VzvnHZ z&)0ErLw4NlPO6~&VeO)Qd>?o{HXz-5V<`P|-Y!yo9p2OuaZR``{%2@qTmHR@Mv}LS z{`i;Dm=BFmSpS8ei76J1oKpSA0c#u?H=*Kb3p2;SZSUmc0 zU~dm?l=*2wrmgpDFV(+v#!Jxkh0py`yRxn<%B9p|KltMI9=A#p?UD@^*83v+>TXnm z$LzyK`9X2e`UnVO0=&2rP_&_lTCnN{E$jSMK)30(jR}z=XEa=Ut6!)aXy( z8G@hdGKY@@Zah%`lB?}FSP^%F_JgJcUeMpMeD=YKVnp9y9Q}H+acFc-4WF!0d~^>4 zDpuB5%ZpIo}EPoIilO4Z-Fsk-G3V zVkbjKZKJDOfu;`^{Fl)aIeam}OAI}hcc>p()aGk0mS~-ouD9_Io6O4Fe+l!AN2}la zCav(U^0rOs`(x2uPs$x^WWe&}0@uWBoRM$lnZfq2kr5B%ow-<`zZA*&ym$e@ukBRe z0Na=00a`pI7=@!lt$2{JB@^TGYgqkgKG;yezhZ*X^tafhmNw!HOL4R5Q+>bLsEFkD z7|BaA3+B6K_h64Rd=l5pICMArN^tW{_|0a>ck)zAW%L_@c`QmQ5g~7>cN9s3coM$5 zZ1F!rNziBsu8o=6KADZ1G8dPFo%Cjyg`0A3Q}*Pz|BnUY&joVe);Eb@*C-O3jWoKF zo||zG$cE?=%qUH!;^}!Y`#?#ji%25k-TK%=!UyI_sBa{}u3ug&)kNvdxFD*B)<_|6+ND z5osLBiv?%f6D&Pie7-EW<5%`dY-AS#X7HpFzifL^xfkxn9M7Y0;od;LA$m1A2bbm3 z$MWyIv`@x?e$xzui}KASv3gI=tG*IkqN(H8Mlw~)vi653gdVWTYcJfnRk(LUc=dUq z&*8m42(&^h6?=p7kqzk+OP{W!xXqL{Y<$qji3JCAOEY6Js`Y4eq+^5w;S^^yUU(*NobA?9CnTKGAeYI`RoI^GM^d`y)AT&eTe^W2t{qmOd^+< zCD}AOx7L~!QPO*OO+= zis{wi0J<1Ld&;>t(r3-iRC_bF`1ooxKQ!>OO3?$52h`>hM=;>A!M5YELux_wRqWA5 zn}R3edeA0*3i^vi=%|e8yjk}#x3SI_GA2@^dbQLq0xuw9?s(HSi;8Z9}v#pu{?-K30{gmmTp(GG{8Ap)H;j zT&H)8(sZ9Q$nDAqy6NJ0sN$lmHl*#`6M|(DZR=g5iFJ)Po&P#TEYBy7haS)kp9@Wx zR+@T_Jo~CiA8!v|SY?dw>b&2Swa&h)xdqs!uv23ls8IkCB^C;_PSyL=3qlUI+K%z$ zxuu(3PAx`Q7THZkGWZx^i$AKfZ*jdcEI%NWaN zI;dCIBq_Tx;^ibt-lUb~rOH*Jl{YfEahTj-aKE{-B=KFE`=YfQN;xd>e*Cx00XoWa z*$I9WO#~0p+oD-qlyR;$(pA>`n@8bdD3VDJLB6#4eJ^2Dl}o- zFt=H#c5Try#y{rwW8w-re&&2Oo9-xRq7i$sPOR)^mNBrjDYHkE5xDtQu+u$vc)!zkV$T_~j@O^L z#-l=ovHW@c1)LN2i4LXl25GBU{?NRDDYjI$`!3c0c}sA)9Y(h$<1)H~=G1r3|8XYG z#R!UgMb!Ii`nTel$1290)~IQsj5m)mG`3@%lu?^~^=oYlx6uj-L{nf}unHHtA8B0# z@TBn**n7Rc3(wAFby%bd@rT5p>N-jz9b(Ea<_qce|*N6_pBTaD-0?1l&s-Jumr#G7fx5`D2> z{aNOuoZ*w>(BpE{e-THE)5qDsZFHv3%6IPN(FEpAYPOx<=`%X(WlQiH^UN9*);U=D zm*!o)Q}TK_rQj373y+r}heWYcj_AUpi#!vr1-@?zU9h+8$!D?;*^eIxy%EvJ3=->B z!mCrI(&VXNkzp6|cacmqXWM7D)Q8Sy>en$`_-N;0yo`DBy$dNRjKDp@aVbk z&7%W|?I9Xdy*N(>M5=eI)zI-*lJKqhb6NQ#(ZrEMJX3XbePPkfh0P%}( zIOk1H^=TY|`D|l4bvS@7hR~jJeK?i5Oa7eeGg@m)tA`mzuw1CE z0!=$!@AO;ho0+>TYnwRCE%_tQ?oc5AF;H_{lR~X~pH!k}y15xJwsW*x*Pn|A!{TeO zpygxgW5d)a8O2g*{DwKQDwe^&z2CgH&qe;c%km{C&DNFg18=Uym55%AyKj^KO19L# z65yYNJNKc0$*Oua%*DZiBTN?6c58Uk4)(TLRL=xU$2#q1Ik)2bWKks-6pxBZ)o+8X zeX^*QEJZPOr*cgEOZ?ewS4U}41%f_yNA%M5Sykg+kHWGV_t$1SKD!v@I<2cE*^9by zRNg^Cu1VoBZSWcW8%^4DYR!47y`A^!vY@qVw#=rz!s+$>wd;aE{!KQsVb-zo(`GX> z+B1(yE$55qUCZ4gf*1dQX76E{nf}0l;dG+VGR+OUYuJqWX3PhhT#`9Z9lAT`i+$zz zt-ATTam$Hk;%fy==6o7bF7{&YNA zVmL;7nsgv z$vk+_Df|{M;JPa=rSKrRm=|wo?Imp~=T46Gd}n3_r1ni%JXu4*Wpy6@-B+RkDT9kzhPGJZ{cxv{?reGw(LOm`Myy2+RpJs z79q5QtV6W3V>3QeLTj4t3jTRIoxgaEw$BHB^pPV@iu7SsqL@Fm1!&bM{qB*ie4k_) z*8L>QSX5oVy=IbSR9-GcjTqN-zA?!%%TJ%+gEPLmw47RRO5;my zMZ{y>kWo-aaO<^YT+aX~or<8c=l3G#b6#ZgxjWL1LxW~-`G$5P;%<=Dy>2yCmaK-g z=2l@(qb}wH;lip#ASGzsZX!RKAtdy#Ld@rF`A$AY?XAlTshPJp6%U-0@RCNx)n~l+ zKJ(EhPOH7;cvkJR+vc_+%Uo#;yuseJj+i;xN~QH$k38wt+~yfP(2POum1u2r@zwh) zWr@U3+Gn?e*6Z9m?|m*dDKdtzg~pztm@5NoK8CiD*S((xqg~_CdEQ4`+q~(RMaMRqBS+ahrl0>@?^t*BI*-_2t@RVUWFn$N!@*yk;v(aH^d;{Liu&zc9; zJj-`jHPU)Ms?A570}K7=_}br7x@j9hSM(LVuSN;(U5Y6|?{-sykDxY+aX2~SE^~96 zkNE0PqM7hZ4O&~3IrX+j;L>6`3$$;2@vE;E_Io|?mNnNW@;!b#hl{ngAzZc@g&T9_ zroY~E`7Ga$94)Pp{y$+AB9UozSNOxe{824i<&@Q8a%;Fx@#I{oOrhkBVjrdUPE5J* zFnZ|f#l4nWA&-N6Rjcd>R$0RigK|c#c(@c4l^({-byDq?+ zQ`15D9h7KMBK5o_W|}`+ZMhFxPhjAL+BQt4E6&<1U9BHhiJvaXEO+m7{d>_7m3Nz| zro_;i5;l+VzN)J-T`|OQw>n#i1~LfxQ=RoQamTn?(wm(hVzbVtsZ~ zE>BL}@!g@IBn>(Y+h-#m$~RYmhYtJRC{Ez@qp5`|7esySls1N=hhhP$CG1|_kL8lHhI76 z%(=0)yLX26C;Zpas?RfYhS~q?xjOCblpwh%)h1>!VBYRkG0gTAK2G zrfiB~c@yQQEt|qf@Qqo}#tz@C~Xp@Hg2(un}&`UXoWzJt_C! zhd;yVM4@Gx8+O;Q8FSp253ZK)b51A{UmkWMY?SrWpvJ7?l&=c+3%IS>?cHS$VCfzA z=jl869>614l~D62V}*pa+!Fr2=kK^jDUJRBi~NBzkI7gz_EgVC?iSv4HG1Q!cXV zPf$-Pg-`O#1BoJ^a*?+~6tq?oz9aa6-@e_s$m@`2;@lG7*K+OIW63?^1?k{j$uss* zO?fdg*lSku>wGNP4D%1a6vb9KiI1T^O=k(kAmC4hz_il#x zbGP%7qvm$Z_DqO0hgZEq#^F^0uo>u%t8{&*9)TavpIf?1Su)-66|~j#y2d@&=W(Ky zjz6cW9|jahB|o&`$FA`VdbU$--Pv2+^SJKJE9*JGTC`4$p2{8?7PKGjfa2t zy2tqMn+Mqs|2{*tRrqFQOV*$?u9VO9&@9Q)`l$8Evrc74l|}hH?7D4HQ0&S7mVca^ z$w_zAw;=a&Prh?vfW}RYn=$E<{glgCKmQsTAg)K`Cm-kMQ)@)1ou}e?jL@d~5^M$J z@z_)5V*9Bp@55=>#?|`d=1iH3D!C8Ic;@Uq>W+9Vn|JLz^&u2=oVhs$XMU}5$0>7h z;*LfueYoS4xj1o0qnGBj4+R}3cWl#S-k;3H*jA^tYL%v`Y|mM`*kh=JvnwYDbE^Ck z`Si0~55w7{XkJg{Nwh0IBg41hHKh`Z^l!^`J0mS(Q{9m2cf;mJv}00{8@hc zc!^$*DzmT8D9C5HLav_IxUu|hwLEEUee6}pnD+uFh0cDH`Mobz zDI#lr6dJYW|L+S0M{048KjwoJEgWWL4wbpNr)rWz5JrE!5 zU6KB53>T!`Yl3a9<+&-J@Wi=C=$uqUf*w8&GUcJb0hK+H=cw!RQrcm^G;iSlDb5ii zprZ1r$TL`)W35|yN@oAAR87T;SQ}f4*D__4F^gpEqd*>L&tZ!(?Vn?dciJNLoK5z1 z939BmZ!C5SGQ0O=y+Nn1w5B8+qDOpaON9Gn+ zdzb5EUmj+`dY_**>z&b$(#{uE`|^fxBhH1=^Jum1+d+`G%M~767T*g}y;TwQXiDq( z-MJc0C;Rd`R+eEi-q&J2xLPf^FN9ydx%Oq%u{|@uBh$;-N$61dJDyF@^-dna%8sb- z#JIP0s#+ob#ml0*?Z`j8l=^FGPkYyD$z5EG7_Id}!1rw#J<;BldxQ@{};C!V9~ z)#PFud%x4L>(y!T=#}P(+3?z1{d&Q2gtg>Au4W6w=BK^adZ8z5@?@knagm;~?KxWU z36RY*wvE#K8e0#^_cDCzj`T9zna|YDb*6%m(rJfHh<*0PJ&U`GmK=^Zg^KV5V4Z|I zPRS>7?zpapTD+CKR)Wv=n@BZ2Pjz}>?T|At>@-w#lcPKjHRemst$@9>_ES!u`X0OU z=-6R~WU!Wek?^ax_vF*F0jnj)cYyv%}qRfExpFF%TyPkM1wKj`q*%J-e;n#MV|KfwBtH!R-w2iT)75s z-5wL;$H(1fn~C3Ws)vUi1aCH0UUJu!?w6^BV9_ZFm3@pCR7yJlgZi=Ce8DcyYGBk^se*aY`A{2OlK_|}qjFg^8HImUD{a#uA0k6`wC0;P4r zJzEJm_NVFsQ~s>cOrHpjb;kS9ukSSmMd{jS=jXltyFX8})4;i>XtDE>DS2KjHM?T3 zUpD>+jP{|Rb;bbEXEz0PKT+e3Q+0ufJ3?c9X?vLGA9AM$4-5@?dSiNwCtu_ zqjyT4E0>Jhyb4pq=Q<+I-j6mcp3c^_(#{_m5uao_JrS;PKI9RQe}KhmdlCIftc|rW zT@9yG#OFHJkYO|C_%R<`E#mVJLbt~s@tLlfc%=5r1+i~jlGV2(|Fbik7b^+&*!k>( z*BP*6#=52#uhdeDn^k+S<_fXKi6kVV%i@{p)sD!8x2N*AsHuKSpuH0EnM$xQN`HG_ z;wAIi>YBmduO;Hqh)GwjgnYwD9EKVMsYM)!ayZV+K9fJPw!2&NioeuX!K2W`OWaN~ z7sTei*%G;5_X_PfRDD`YD-owN9Ya>b7cmO=ggW+QY*dyhkI`Wo(oXjX`?cmLOzsL5 zScQ=OG@-QgLf+;5$BU{HCCWIL(M5d**3}Nxd#D;kd#rrTf$m4^_!TvVfh>IW&HtL__Sri0DlMKcMhnCU7K2%+NQSF7atl?U^PT+98Db5G3v76GH=K5+b*a( zEVVpy%={t4OO2B}6S^?UfG25n6i!=EehI!)4E1d(&SPjwZ_7$HE{A}FeW8Np4AdaJ zFHfta3@6$R9O+5manL3BeH2=2gSI}q?XCYPtutFLsn=vipf8P}Uah9)#qFcrXgy4J zVPu)Qj$-okGS^tYq25Aibj!3GzhihEtNmCn8V5_wopau*^Tned`nlPc>I`FH&-;t@ zrg89C(mKW(m+|4T+RwF=aWH0*uJV9`(Wow!DBAUt@h}=|T4haU94x1!k7cuQ`padm zae9fRv$5tZmVC6ov3e@Wcw_aIOM_$e6JyW#mCKFeP(`~en!Jj>A{Aw(!p5!aT z^t!I8lrza!tKxN%ua?E&Bwy{1sL8ci(sKD~Ig5|i*uE~ca*69AKJ16rnP!_JPifuZ z>p|)wR|pA3%;3yr7UTif{|4$aIrOSIZJ7u6>ainDU#sy;!J|r zd$1gh86>fFZ-`&R-fz1$Wx*!a);E%7Z{5)VtKrUjjBR_(F?L)0+puWAm8^Ru8aXrT zA5&m$w_QyVJ&L|^sdU{GncMryV;T~_(1tnttt1)NeD|dhuSTV%-VG1SL><_u+OBDz zvBht=H@2-G`z^Ql4e_#C8*SHE7R~*QLp-r^poX=)kE+WYQxJu`~eb@I73S7>nHv3#lGG^I} zH+eyul&5!03NjmB8Gqw?L1T;Fy4S!ETVAQ}Wp)q8b*Xp5xXGQRURPQ5T@vTI`%A|d zTkgj3?>75OEqCi4UoK@%{$!``(x;MyS(=m8R#q-suD^#asWQ#MPW{Ql*YD&-Ezwfx z-sD9sVWoDjDFePsIT+3ALE~5&$~7v80X>TTN)?F4>X*7#X|1BMw084*jMe_+1F!Lf zKKD~8Yx03>tt*q+$60+T&SOdXsQODK>2Z3^<>_&HnS9`VR(a`}T(TaEKex-*<4{F= zou8xWGp-0UPLE}2#qw&#iY~Y)RfDj|X(h*(@=0q7PB8|hRi^i1>+d+U(3Jn*orp~z zTby$<4jxNu>gakhoo%>Xp-y}DOFFVi*D$;cxlX#q5NzeorgHD3YfQREP9e*FpLC7k zm@C=u$I<~NU1RwCw7rq*H^;4OEa&5S-=lBNjuL%Cjnk>-LB4uo4XortTt(t`{lv57 z-lg~(A78A0wPm@kg3VMusdI{+((`0inKg^$nWCqL zp0-e0b@{!LUT7FMPt3Yk#S}f&zmj}DU#0K41~x@cm9XUZO4?V6#+Q?y!oy~Y79Ti!LZeK&3lVAuA`KM;py;+8$GF zkDMmjzq{sOnvr=pR^w~6UcJ9qQ#m^S&C&H_cwA`cXtIj9mN=rVm?!ztyZ(<>3ZXgHrM^e>1B%a>$fK~pUSnsv37}eU2q(#$n~;R z3p|=WV_k5Z9?PqH>`1?>p|UttyQkQ`=Blzgv1e(V*>CREQ*57Mf5^48ipH6-Qcsh{ zHe{}v&rW$nO`O#4Od1(gNH9%C(OWu<6@vexju^QEwep_1K>ptHr&toga1+7ApxnHt8 zrtz!Iy^x5Y!@x5ihI0}5w!TV;O+7HxjY?QujYgV1rrxYlkE_gMv%gf+U3Y)ZIqP1@ zb@$n(-In@VZ3ffc#+|*iuW@ItvvspSQgdtPn-s?kbU&d@k>d-R^X2cj!I zUYsaTtmjlMu0|21`z0A`to4{nT4VLoE^m!hY3%Q_m%>l@Hy7^mKy-Q5!gQKhiR$d$ z_|Zty?rga3d$m1l>?r+dcZNGCPgL8()7ew`zAt=ZyjYNYw=|pMQAq>S?%a1B^4$Bk zJ1-{-zwf^0KMJkNKyG*hCQ<@lbB-NtOvL&?ri>U9-b?XoYdyT7_+VLH*t z=%DQyXQbsmhtspqXD4OnxHel)bU;aNDbd4fRG-@u*55Qp4t=)^WOS20S-En?)Q$Ee*^Gne&4#d{^Lhjy`PlvN_MNZ(#y(AU zKKnXcOKk(uwzPUB^syt~9RDAS&T>yQm%F0DJP=!|e~Nd@kEPegizkd@xt8gz?aEVF zWZl0WM<&Jh-S4ia-juvSwXrZBmm5Ej(LazLpUkd?ykcZ2Fm!%KM%li6D@#yd4XlH^ zuV(*{{~hWaI{zge&pg5!M z^7+5yTa2H6Ew@vx{fggfN9b%m+luh(wPHS&`}Y@An%C{Oyriw!-(-Gbn%fFgP0Y+o z`9vF+f-b%Dn&!4-d|JiWW|XIVhK=sFqB)Fbil==J^Vy~U=Iqt*{exioa#%}XVM{2{ z@V_goY)7El5njA4IQmlleOg@YU&%Y)NGsQhzZ$k#v&`jISb6w6bfsy_8^Ui4#uM_C z{-x_298sr;6PUh}D_jGpF35eJtj*(m#we9CH{?mU!gJ~WN125~>DPLj3w+Jzm=~S` zI)8GUPcfWV1iD8u*4Tn;y~c3rb8rnTy~hP@{d|iQtM=S+!5L@g8aC}3W7VHKE=cQk z{1l^qPiSO)(6U}GzFw1tqx^bVI0ox3-e2dlzskLHtt+M<&#>NDdnXou-eZ%?5y=Fv zx+Yv5USo3PT-F7n0aE9jF;AV({t}?xc>VjX@D+FszS&)QpB>;|vL@jkyTb48%6C5P z$S>$S{W!$1aohO0`kT!EP1)mzawNqZdn#Dkk$;==FP5ZEOFywJaz)0tKl@2=a9^GT z8?VCuH$o)1ax0bao(pCU0&bAJlrNWeqTzn8c;rLJ4CZ|2(b-gs)ULq$d;#g{!MOC* z5zkTAXK)QPLr38l82Tm*+0UW}nsKYIIcWIO;m zd;6ew-7KErl7?EB-QsnjRtVOguIzh3BHN$+_Il<^ZNGhZ^EGJP8OrV_WBR*q!l#&i z;jSuKaNQ5z*d2*idLiHb6lPI*>Q=)_!YtYz5P#ND+8%=Z8Cw@jt{;Lsml5KA;?Is* z-wSo8e<&3BQpR>)#)5TXxNPZdr=Q~f)kZ?!@h<50k;_5bq5q4bIh+?g*_k0o)dQ$OXB(Bkw+wCl6+KW~XMi7j5b1{_WopXkwi~-@F>2L&q?C zPSeiA$WvT2zopnYAyBJkik10BkigOzF-qcEo^O7kpIUtUda<)B_Ndq*4z@NIvj>j8 z?KOwQGCE#)XHUk?tUs1dTs1cJLD1x$h0h>?Zkx&Xs*PCj0F>b-& z_X7VFu_Im*?T1mtGYrkq{^{^PtNur!g+0+aFGjuR5?-?(mw4mejeF+QG0pgS@h~V= z9oLM1y0#h5XZQEB4~3$(WxsqZTx%XU3-UUA85vPIweC959<;1G(kuD=I6T9%bK!K@ zd1&LVy#0$@b#=|9hu;TzET%T+Is3ADE=6zqP7puePKB2!Z#xw1O?`seFDFKJUp|QcXrFxKUc!(tm-Ui*&N zM(_BVY_^7zepi>OYc`?ba&`CWE5T+fa{0L*`X*2~@1Jb8@d}J>q08X4o37q2o2_%# zvPDz(?55AVKkm9Q)^{ZiUrF74k6~vnae>l3po_KdR1-3JX|h3=aQ7zPi!GHkJG|NO z-!EIV&6@6{YNzYZN$l-6*EJKy+22+hwc#PA>)2MUajMTnHeFmS@wH@||S34cj%3A?wrk+o87Xp}oZW=DT6FCbAGq z$n!-+=#Y7b{%r1R_G+WiuIq9$uMk|5F%Uyc?372xPIhiQCFzvth27YDe7bJq@7vb$tHtd@ z>+=otg*tt1-QI(=^}gQ>iq-uKeS1uwv;LR$K%}kJzxg_^vPZN+h3jH8}=l}1V&->l$Cd=V%R_|w09G{}$o?3*(ieRE8h zjeiRCo{Q8R!#blAyZKTZH);FL=EyZ&GAjQWJp5`a*ZrOS)v_drSV=h(c@lkkvEGJU zJ^Cu|m0ZOe(legyv3jpVdQ~EjP69;AsYxRuJ{4%jp{sr} zQwsHR-%`$%$I+RWYC|L`wcdUt^F#E=_X|tVro;xN(LkHRfxrxrQ;NOPZ1bx|l$;EC z73`3g1D_?%lV~jBugWo54hfmPJHmf!v!s-g!^g=k)G%O0(JwLK#20JScrz!&)?`_l zv{rae*KR2@gnrW85blhV9pYJvM0FB@^;mcd@oEZVEoNpMT3(JW-?X<}+OA;_`rQ^B zdsb;I<826k_Z$=`C2r?!&q5hzwp7l0+x>{^#f@vXF-4ZLTAUv9Z0D3NoiD*1_(Q9P zUs&FZQfsM?iDT&Onk`&8EI6DnW0=uwTy{F}Vp%-4`<3%}*1Kl%)?7w^vveqjvn(+k zCr#!06tEsWJU(+KYpqkeI_mMndPc4}57DVg)RJmb$D>C%J;x)h$?8-EX^$`W_J)5_ zS)z?E_nH0Juc9>(H0Od^5xb(X{38GMM4Qma4(vvEWK>)7U9CuHJ=cT_mULyZEDl3V zep%1Z{=8k@yi>Z*^Z5+$Y<>^wEL#AYcVo==Svh^4G2bb6^EgMBIwNF& zB0>C4*3UEfgteL2D${VOLBlypT5X5wVSDmT^c6v#0tJ=;VApy%zz!6Ba5UU9^0EaYu1$BAfVst(Yk>GtXXIquuO_o2R{iCb%fGX8A{@0{Y> zV$8*#V?AtLx$klN{Xh4K>>}o0Wi93HZQ1etdybzpD5m%}!%FwQpidl!70Y03zqWA- zufvQzfz>cx9c+WrBmPq@JJyoht#Rm~sc%#@*+bFD-i~_MPF1DZp{D)ypnnjB*j3ZM z)B+I@)WV@1JU!HI=-XDQJ(a$%O9i99NlO=`J+0!jDcUABDk^}$KTpYDpW5-fUET^%eLP(F ztq7^wJ2nN?FSSk#-#3GG0Sn+bzdne5SiI zl%kO!FCMawxH%F%Pa4kT{Rg9FEQ;n;pzdNV&~W=}Y(Rw9S<$LGn| zetSjw)3arMkX?${#a-F8uE}ooj{u3DcyU?Yw&zOyrZ&TE>FFyO1$ah=`bPE%_o2Xz z>4{%}_rK&J;Y!}~ia9CNeM z=Q6F;BPreI`&96t(u(bq>X9hR(aGp=U>9Tl8q8hpDcl~w%xVtvD1z%1tnZHjz_+=q8trLq#0 z`q@a%qj;|LY?tnrwqP9JuCW$(L!jJ#EeqNccEx8OpZ)VN$fVT#<7@=i*>oQ$d+t;I zUK$O(wR8BUPflZr(r95kb7a?>Y-K!Q9yq?m_p)p04uC{&u}H*XDlUj_R(`xGvvoFb z*Z7X@VWp9bF)ub3c6B|c1VOBSwo^e_&rIJb^kXxXp?l^*(0t=j~TvVwzY`)zd!*6Yo(9#vk8PuoGeA5!_bMzwz5`f3~9S?QIY zbE&gNg-)m5kA5ou(!8s8N)>>eQYK6FWCt9>4yZhoIAP9K`CfD)Dla^ge{q~D7Hh5M zj{o6>NW8=~?#a{qf~UfLA{JAsk&pVszPv^DVeTFLZP7x$a^9}*W?P*obPNiOdEjc6 zYN&jDw(8P;(4~iJq%G$k_>-&`&XPEk2xokI>^)^$ioc_4k@d%W@jF0e?Yp*lbM|+! zYGAc#R@k?bs_|IrQ$#2O)eBj#ocg0y{eQ~4cse;Z-Jex1p*A7(K+oonpVEpmeqM}0 z$vSs?)CZ!clOcO3u!55pf+e>y#qYR9_*;SWu~^yc{Gt5xp_>A)X{VkCy(<+xY&3bL z5IXm05(|ln?g7n7;Y>V)mIu<%4ELHVATT>U(x#!+G%{TokM0kMhSH zd?I!%uIf>?6MOVr2ghl%PD8ynY)4dSu(!G99NT1bu&<|vsPzR(fx3Q@H*_yS?qScl zD}EO!tr^*`UQx!tF7hOt*1{(!Kc(pBa?gCIQ1K)Argk5`ksn~ZI)_(fd1UT-RTslZ z+UGrKnHnQ_B!JP^vsr$fTKiGBo{usYKT&Ri349tgr&PxO+B2(CGg`n#d2}DY#!}A5SUpw|Waw;mVQI)3G;B7naTa4AYKc8@ zzmxSGucbDKT}R|8@N4{(s?z@wJf#wV=8iJ=P3~%PJJ{uPE6bBY)*w0wF9;L@r_>Wt zk?xc?Z`uoMPm|@Fs8BpUmyJaaX) z4}Sk85CM(XKD#HD1$>a4U{{jb?G(@-q+e>7K%>{BO^x39Zh^y6-+z;*fR(W=*EfE{ zhw?W3i`6(B2H+x=h-i!Rf-7Q+`i>a-`KlLoG`_bs2i~f88>C z>Q!)pt%kB!zJ(KoT!sM)B&PGw06s(o6UHFyEwe5uU-VD>FtM6xZslnnDsgPUV`H_Or1&xpN-_uGk z**(ThUeHZx+4)32I8&L}Z7M*C1hZ~f6=vf!`7EJxK*3N4CyVwA9_T$L_5iS zlia8F+)3`cy+(=8tU;+2XOiXWvYcDHw1WC^%5*OIuSc3QT~T$a>q2MPYO%IM5wV== z()2vo#j&Yl0oOX`P5Ioc^`)w2UT+NBFqRrL+`Zr*rB%I)&5v0@KGiG;v!R-6d$>nHPBZOL$0i3WFoQnrDf6ba>{W7VNU>XICh5T74={u&-J)&4Un6flf~aKK1v^ z1BIx~1*@Azf~lt=r_LsAn$<+D`q+5U;bWaYuiVR-D=~$T^RXZ7LH9-XcJ6aSY%FN7 z-v;d%TZY=cj3+2Zu=&AKQo^fa(Ci#BZ0xwXjlNF=j(b}ycA&j)hobo@#YJ~q4H#F8 zskOC^_ycQecpL)y{?=k{+>6x2kj5RHtJwZi`j1DL&QISM1NHyEsWAiCJk>)#MFJS* z<=5fsf)-+a(Z};2Q*UjDi6L8_8v8}N)L`&PgBThY1 zoo4i5izj>6yaGAA_C4h_ZT;{DGtQp2751hVVrxe}+ZSu6?m*@J-1w{Att&)?bVN@VFvcAoCU<2(SfA=u_j2hCG|c6Vxa?#+b=E z8v-Y?ik&nB-hmn^0l5Y_8Gi_J5O;}c!hgmyJc}J%YY2mlmm$tYE4y`hMid&OGb9vh z{CI23T=&eUlopS$^x0zvjxv+TAnB8Hv)+uNyyv6HEXw<|sMn`5ziAxYZaAM$_lK)O zQTRJFeyfXPIA65h@~b~lYAeqUukiCw?vyhH1sE=x z)xC^9jPH3gJ@Fgg$-6}0p#f>c&wb(AF%N8VGvi$PRK91Wc?)$el}kJ4gYL;`fR}|v zbpNwTndq7tbArwZ$9yDfN@EvzgA4_I%O$(pqTOAPyPg-IeqU`%Klg9{jzAR4fBNQC z@o=YpnvH4 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 diff --git a/orphaned users.sql b/orphaned users.sql new file mode 100644 index 0000000..eec238c --- /dev/null +++ b/orphaned users.sql @@ -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 + diff --git a/paul randal wait analysis.sql b/paul randal wait analysis.sql new file mode 100644 index 0000000..2cfcc2c --- /dev/null +++ b/paul randal wait analysis.sql @@ -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 \ No newline at end of file diff --git a/repl.sql b/repl.sql new file mode 100644 index 0000000..5d6a569 --- /dev/null +++ b/repl.sql @@ -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 diff --git a/search object owner before deletion of user.sql b/search object owner before deletion of user.sql new file mode 100644 index 0000000..900153a --- /dev/null +++ b/search object owner before deletion of user.sql @@ -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]; diff --git a/sl2007 cloud publication scripted.sql b/sl2007 cloud publication scripted.sql new file mode 100644 index 0000000..ddf2695 --- /dev/null +++ b/sl2007 cloud publication scripted.sql @@ -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 + diff --git a/tde encryption status.sql b/tde encryption status.sql new file mode 100644 index 0000000..1fc8575 --- /dev/null +++ b/tde encryption status.sql @@ -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; diff --git a/tde status.sql b/tde status.sql new file mode 100644 index 0000000..0f7ce89 --- /dev/null +++ b/tde status.sql @@ -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 \ No newline at end of file diff --git a/update medifilm path.sql b/update medifilm path.sql new file mode 100644 index 0000000..9a3b825 --- /dev/null +++ b/update medifilm path.sql @@ -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 \ No newline at end of file diff --git a/used space in tables.sql b/used space in tables.sql new file mode 100644 index 0000000..5a56b32 --- /dev/null +++ b/used space in tables.sql @@ -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; \ No newline at end of file diff --git a/wac.sql b/wac.sql new file mode 100644 index 0000000..dc67b05 --- /dev/null +++ b/wac.sql @@ -0,0 +1,5521 @@ +USE master +IF OBJECT_ID('dbo.sp_whoisactive') IS NOT NULL + DROP PROCEDURE dbo.sp_whoisactive; +GO +/* +kill 98 +*/ +GO +SET QUOTED_IDENTIFIER ON; +SET ANSI_PADDING ON; +SET CONCAT_NULL_YIELDS_NULL ON; +SET ANSI_WARNINGS ON; +SET NUMERIC_ROUNDABORT OFF; +SET ARITHABORT ON; +GO + +IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_WhoIsActive') + EXEC ('CREATE PROC dbo.sp_WhoIsActive AS SELECT ''stub version, to be replaced''') +GO + +/********************************************************************************************* +Who Is Active? v12.00 (2021-11-10) +(C) 2007-2021, Adam Machanic + +Feedback: https://github.com/amachanic/sp_whoisactive/issues +Releases: https://github.com/amachanic/sp_whoisactive/releases +Docs: http://whoisactive.com + +License: + https://github.com/amachanic/sp_whoisactive/blob/master/LICENSE +*********************************************************************************************/ +ALTER PROC dbo.sp_WhoIsActive +( +--~ + --Filters--Both inclusive and exclusive + --Set either filter to '' to disable + --Valid filter types are: session, program, database, login, and host + --Session is a session ID, and either 0 or '' can be used to indicate "all" sessions + --All other filter types support % or _ as wildcards + @filter sysname = '', + @filter_type VARCHAR(10) = 'session', + @not_filter sysname = '', + @not_filter_type VARCHAR(10) = 'session', + + --Retrieve data about the calling session? + @show_own_spid BIT = 0, + + --Retrieve data about system sessions? + @show_system_spids BIT = 0, + + --Controls how sleeping SPIDs are handled, based on the idea of levels of interest + --0 does not pull any sleeping SPIDs + --1 pulls only those sleeping SPIDs that also have an open transaction + --2 pulls all sleeping SPIDs + @show_sleeping_spids TINYINT = 1, + + --If 1, gets the full stored procedure or running batch, when available + --If 0, gets only the actual statement that is currently running in the batch or procedure + @get_full_inner_text BIT = 0, + + --Get associated query plans for running tasks, if available + --If @get_plans = 1, gets the plan based on the request's statement offset + --If @get_plans = 2, gets the entire plan based on the request's plan_handle + @get_plans TINYINT = 0, + + --Get the associated outer ad hoc query or stored procedure call, if available + @get_outer_command BIT = 0, + + --Enables pulling transaction log write info, transaction duration, and the + --implicit_transaction identification column + @get_transaction_info BIT = 0, + + --Get information on active tasks, based on three interest levels + --Level 0 does not pull any task-related information + --Level 1 is a lightweight mode that pulls the top non-CXPACKET wait, giving preference to blockers + --Level 2 pulls all available task-based metrics, including: + --number of active tasks, current wait stats, physical I/O, context switches, and blocker information + @get_task_info TINYINT = 1, + + --Gets associated locks for each request, aggregated in an XML format + @get_locks BIT = 0, + + --Get average time for past runs of an active query + --(based on the combination of plan handle, sql handle, and offset) + @get_avg_time BIT = 0, + + --Get additional non-performance-related information about the session or request + --text_size, language, date_format, date_first, quoted_identifier, arithabort, ansi_null_dflt_on, + --ansi_defaults, ansi_warnings, ansi_padding, ansi_nulls, concat_null_yields_null, + --transaction_isolation_level, lock_timeout, deadlock_priority, row_count, command_type + -- + --If a SQL Agent job is running, an subnode called agent_info will be populated with some or all of + --the following: job_id, job_name, step_id, step_name, msdb_query_error (in the event of an error) + -- + --If @get_task_info is set to 2 and a lock wait is detected, a subnode called block_info will be + --populated with some or all of the following: lock_type, database_name, object_id, file_id, hobt_id, + --applock_hash, metadata_resource, metadata_class_id, object_name, schema_name + @get_additional_info BIT = 0, + + --Get additional information related to workspace memory + --requested_memory, granted_memory, max_used_memory, and memory_info. + -- + --Not available for SQL Server 2005. + @get_memory_info BIT = 0, + + --Walk the blocking chain and count the number of + --total SPIDs blocked all the way down by a given session + --Also enables task_info Level 1, if @get_task_info is set to 0 + @find_block_leaders BIT = 0, + + --Pull deltas on various metrics + --Interval in seconds to wait before doing the second data pull + @delta_interval TINYINT = 0, + + --List of desired output columns, in desired order + --Note that the final output will be the intersection of all enabled features and all + --columns in the list. Therefore, only columns associated with enabled features will + --actually appear in the output. Likewise, removing columns from this list may effectively + --disable features, even if they are turned on + -- + --Each element in this list must be one of the valid output column names. Names must be + --delimited by square brackets. White space, formatting, and additional characters are + --allowed, as long as the list contains exact matches of delimited valid column names. + @output_column_list VARCHAR(8000) = '[dd%][session_id][sql_text][sql_command][login_name][wait_info][tasks][tran_log%][cpu%][temp%][block%][reads%][writes%][context%][physical%][query_plan][locks][%]', + + --Column(s) by which to sort output, optionally with sort directions. + --Valid column choices: + --session_id, physical_io, reads, physical_reads, writes, tempdb_allocations, + --tempdb_current, CPU, context_switches, used_memory, physical_io_delta, reads_delta, + --physical_reads_delta, writes_delta, tempdb_allocations_delta, tempdb_current_delta, + --CPU_delta, context_switches_delta, used_memory_delta, tasks, tran_start_time, + --open_tran_count, blocking_session_id, blocked_session_count, percent_complete, + --host_name, login_name, database_name, start_time, login_time, program_name + -- + --Note that column names in the list must be bracket-delimited. Commas and/or white + --space are not required. + @sort_order VARCHAR(500) = '[start_time] ASC', + + --Formats some of the output columns in a more "human readable" form + --0 disables outfput format + --1 formats the output for variable-width fonts + --2 formats the output for fixed-width fonts + @format_output TINYINT = 1, + + --If set to a non-blank value, the script will attempt to insert into the specified + --destination table. Please note that the script will not verify that the table exists, + --or that it has the correct schema, before doing the insert. + --Table can be specified in one, two, or three-part format + @destination_table VARCHAR(4000) = '', + + --If set to 1, no data collection will happen and no result set will be returned; instead, + --a CREATE TABLE statement will be returned via the @schema parameter, which will match + --the schema of the result set that would be returned by using the same collection of the + --rest of the parameters. The CREATE TABLE statement will have a placeholder token of + -- in place of an actual table name. + @return_schema BIT = 0, + @schema VARCHAR(MAX) = NULL OUTPUT, + + --Help! What do I do? + @help BIT = 0 +--~ +) +/* +OUTPUT COLUMNS +-------------- +Formatted/Non: [session_id] [smallint] NOT NULL + Session ID (a.k.a. SPID) + +Formatted: [dd hh:mm:ss.mss] [varchar](15) NULL +Non-Formatted: + For an active request, time the query has been running + For a sleeping session, time since the last batch completed + +Formatted: [dd hh:mm:ss.mss (avg)] [varchar](15) NULL +Non-Formatted: [avg_elapsed_time] [int] NULL + (Requires @get_avg_time option) + How much time has the active portion of the query taken in the past, on average? + +Formatted: [physical_io] [varchar](30) NULL +Non-Formatted: [physical_io] [bigint] NULL + Shows the number of physical I/Os, for active requests + +Formatted: [reads] [varchar](30) NULL +Non-Formatted: [reads] [bigint] NULL + For an active request, number of reads done for the current query + For a sleeping session, total number of reads done over the lifetime of the session + +Formatted: [physical_reads] [varchar](30) NULL +Non-Formatted: [physical_reads] [bigint] NULL + For an active request, number of physical reads done for the current query + For a sleeping session, total number of physical reads done over the lifetime of the session + +Formatted: [writes] [varchar](30) NULL +Non-Formatted: [writes] [bigint] NULL + For an active request, number of writes done for the current query + For a sleeping session, total number of writes done over the lifetime of the session + +Formatted: [tempdb_allocations] [varchar](30) NULL +Non-Formatted: [tempdb_allocations] [bigint] NULL + For an active request, number of TempDB writes done for the current query + For a sleeping session, total number of TempDB writes done over the lifetime of the session + +Formatted: [tempdb_current] [varchar](30) NULL +Non-Formatted: [tempdb_current] [bigint] NULL + For an active request, number of TempDB pages currently allocated for the query + For a sleeping session, number of TempDB pages currently allocated for the session + +Formatted: [CPU] [varchar](30) NULL +Non-Formatted: [CPU] [bigint] NULL + For an active request, total CPU time consumed by the current query + For a sleeping session, total CPU time consumed over the lifetime of the session + +Formatted: [context_switches] [varchar](30) NULL +Non-Formatted: [context_switches] [bigint] NULL + Shows the number of context switches, for active requests + +Formatted: [used_memory] [varchar](30) NOT NULL +Non-Formatted: [used_memory] [bigint] NOT NULL + For an active request, total memory consumption for the current query + For a sleeping session, total current memory consumption + +Formatted: [max_used_memory] [varchar](30) NULL +Non-Formatted: [max_used_memory] [bigint] NULL + (Requires @get_memory_info = 1) + For an active request, the maximum amount of memory that has been used during + processing up to the point of observation for the current query + +Formatted: [requested_memory] [varchar](30) NULL +Non-Formatted: [requested_memory] [bigint] NULL + (Requires @get_memory_info = 1) + For an active request, the amount of memory requested by the query processor + for hash, sort, and parallelism operations + +Formatted: [granted_memory] [varchar](30) NULL +Non-Formatted: [granted_memory] [bigint] NULL + (Requires @get_memory_info = 1) + For an active request, the amount of memory granted to the query processor + for hash, sort, and parallelism operations + +Formatted: [physical_io_delta] [varchar](30) NULL +Non-Formatted: [physical_io_delta] [bigint] NULL + (Requires @delta_interval option) + Difference between the number of physical I/Os reported on the first and second collections. + If the request started after the first collection, the value will be NULL + +Formatted: [reads_delta] [varchar](30) NULL +Non-Formatted: [reads_delta] [bigint] NULL + (Requires @delta_interval option) + Difference between the number of reads reported on the first and second collections. + If the request started after the first collection, the value will be NULL + +Formatted: [physical_reads_delta] [varchar](30) NULL +Non-Formatted: [physical_reads_delta] [bigint] NULL + (Requires @delta_interval option) + Difference between the number of physical reads reported on the first and second collections. + If the request started after the first collection, the value will be NULL + +Formatted: [writes_delta] [varchar](30) NULL +Non-Formatted: [writes_delta] [bigint] NULL + (Requires @delta_interval option) + Difference between the number of writes reported on the first and second collections. + If the request started after the first collection, the value will be NULL + +Formatted: [tempdb_allocations_delta] [varchar](30) NULL +Non-Formatted: [tempdb_allocations_delta] [bigint] NULL + (Requires @delta_interval option) + Difference between the number of TempDB writes reported on the first and second collections. + If the request started after the first collection, the value will be NULL + +Formatted: [tempdb_current_delta] [varchar](30) NULL +Non-Formatted: [tempdb_current_delta] [bigint] NULL + (Requires @delta_interval option) + Difference between the number of allocated TempDB pages reported on the first and second + collections. If the request started after the first collection, the value will be NULL + +Formatted: [CPU_delta] [varchar](30) NULL +Non-Formatted: [CPU_delta] [int] NULL + (Requires @delta_interval option) + Difference between the CPU time reported on the first and second collections. + If the request started after the first collection, the value will be NULL + +Formatted: [context_switches_delta] [varchar](30) NULL +Non-Formatted: [context_switches_delta] [bigint] NULL + (Requires @delta_interval option) + Difference between the context switches count reported on the first and second collections + If the request started after the first collection, the value will be NULL + +Formatted: [used_memory_delta] [varchar](30) NULL +Non-Formatted: [used_memory_delta] [bigint] NULL + Difference between the memory usage reported on the first and second collections + If the request started after the first collection, the value will be NULL + +Formatted: [max_used_memory_delta] [varchar](30) NULL +Non-Formatted: [max_used_memory_delta] [bigint] NULL + Difference between the max memory usage reported on the first and second collections + If the request started after the first collection, the value will be NULL + +Formatted: [tasks] [varchar](30) NULL +Non-Formatted: [tasks] [smallint] NULL + Number of worker tasks currently allocated, for active requests + +Formatted/Non: [status] [varchar](30) NOT NULL + Activity status for the session (running, sleeping, etc) + +Formatted/Non: [wait_info] [nvarchar](4000) NULL + Aggregates wait information, in the following format: + (Ax: Bms/Cms/Dms)E + A is the number of waiting tasks currently waiting on resource type E. B/C/D are wait + times, in milliseconds. If only one thread is waiting, its wait time will be shown as B. + If two tasks are waiting, each of their wait times will be shown (B/C). If three or more + tasks are waiting, the minimum, average, and maximum wait times will be shown (B/C/D). + If wait type E is a page latch wait and the page is of a "special" type (e.g. PFS, GAM, SGAM), + the page type will be identified. + If wait type E is CXPACKET, CXCONSUMER, CXSYNC_PORT, or CXSYNC_CONSUMER the nodeId from the + query plan will be identified + +Formatted/Non: [locks] [xml] NULL + (Requires @get_locks option) + Aggregates lock information, in XML format. + The lock XML includes the lock mode, locked object, and aggregates the number of requests. + Attempts are made to identify locked objects by name + +Formatted/Non: [tran_start_time] [datetime] NULL + (Requires @get_transaction_info option) + Date and time that the first transaction opened by a session caused a transaction log + write to occur. + +Formatted/Non: [tran_log_writes] [nvarchar](4000) NULL + (Requires @get_transaction_info option) + Aggregates transaction log write information, in the following format: + A:wB (C kB) + A is a database that has been touched by an active transaction + B is the number of log writes that have been made in the database as a result of the transaction + C is the number of log kilobytes consumed by the log records + +Formatted/Non: [implicit_tran] [nvarchar](3) NULL + (Requires @get_transaction_info option) + For active read-write transactions, returns on "ON" the transaction has been started as a result + of the session using the implicit_transactions option, or "OFF" otherwise. + +Formatted: [open_tran_count] [varchar](30) NULL +Non-Formatted: [open_tran_count] [smallint] NULL + Shows the number of open transactions the session has open + +Formatted: [sql_command] [xml] NULL +Non-Formatted: [sql_command] [nvarchar](max) NULL + (Requires @get_outer_command option) + Shows the "outer" SQL command, i.e. the text of the batch or RPC sent to the server, + if available + +Formatted: [sql_text] [xml] NULL +Non-Formatted: [sql_text] [nvarchar](max) NULL + Shows the SQL text for active requests or the last statement executed + for sleeping sessions, if available in either case. + If @get_full_inner_text option is set, shows the full text of the batch. + Otherwise, shows only the active statement within the batch. + If the query text is locked, a special timeout message will be sent, in the following format: + + If an error occurs, an error message will be sent, in the following format: + + +Formatted/Non: [query_plan] [xml] NULL + (Requires @get_plans option) + Shows the query plan for the request, if available. + If the plan is locked, a special timeout message will be sent, in the following format: + + If an error occurs, an error message will be sent, in the following format: + + +Formatted/Non: [blocking_session_id] [smallint] NULL + When applicable, shows the blocking SPID + +Formatted: [blocked_session_count] [varchar](30) NULL +Non-Formatted: [blocked_session_count] [smallint] NULL + (Requires @find_block_leaders option) + The total number of SPIDs blocked by this session, + all the way down the blocking chain. + +Formatted: [percent_complete] [varchar](30) NULL +Non-Formatted: [percent_complete] [real] NULL + When applicable, shows the percent complete (e.g. for backups, restores, and some rollbacks) + +Formatted/Non: [host_name] [sysname] NOT NULL + Shows the host name for the connection + +Formatted/Non: [login_name] [sysname] NOT NULL + Shows the login name for the connection + +Formatted/Non: [database_name] [sysname] NULL + Shows the connected database + +Formatted/Non: [program_name] [sysname] NULL + Shows the reported program/application name + +Formatted/Non: [additional_info] [xml] NULL + (Requires @get_additional_info option) + Returns additional non-performance-related session/request information + If the script finds a SQL Agent job running, the name of the job and job step will be reported + If @get_task_info = 2 and the script finds a lock wait, the locked object will be reported + +Formatted/Non: [start_time] [datetime] NOT NULL + For active requests, shows the time the request started + For sleeping sessions, shows the time the last batch completed + +Formatted/Non: [login_time] [datetime] NOT NULL + Shows the time that the session connected + +Formatted/Non: [request_id] [int] NULL + For active requests, shows the request_id + Should be 0 unless MARS is being used + +Formatted/Non: [collection_time] [datetime] NOT NULL + Time that this script's final SELECT ran + +Formatted/Non: [memory_info] [xml] NULL + (Requires @get_memory_info) + For active queries that require workspace memory, returns information on memory grants, + resource semaphores, and the resource governor settings that are impacting the allocation. +*/ +AS +BEGIN; + SET NOCOUNT ON; + SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + SET QUOTED_IDENTIFIER ON; + SET ANSI_PADDING ON; + SET CONCAT_NULL_YIELDS_NULL ON; + SET ANSI_WARNINGS ON; + SET NUMERIC_ROUNDABORT OFF; + SET ARITHABORT ON; + + IF + @filter IS NULL + OR @filter_type IS NULL + OR @not_filter IS NULL + OR @not_filter_type IS NULL + OR @show_own_spid IS NULL + OR @show_system_spids IS NULL + OR @show_sleeping_spids IS NULL + OR @get_full_inner_text IS NULL + OR @get_plans IS NULL + OR @get_outer_command IS NULL + OR @get_transaction_info IS NULL + OR @get_task_info IS NULL + OR @get_locks IS NULL + OR @get_avg_time IS NULL + OR @get_additional_info IS NULL + OR @find_block_leaders IS NULL + OR @delta_interval IS NULL + OR @format_output IS NULL + OR @output_column_list IS NULL + OR @sort_order IS NULL + OR @return_schema IS NULL + OR @destination_table IS NULL + OR @help IS NULL + BEGIN; + RAISERROR('Input parameters cannot be NULL', 16, 1); + RETURN; + END; + + IF @filter_type NOT IN ('session', 'program', 'database', 'login', 'host') + BEGIN; + RAISERROR('Valid filter types are: session, program, database, login, host', 16, 1); + RETURN; + END; + + IF @filter_type = 'session' AND @filter LIKE '%[^0123456789]%' + BEGIN; + RAISERROR('Session filters must be valid integers', 16, 1); + RETURN; + END; + + IF @not_filter_type NOT IN ('session', 'program', 'database', 'login', 'host') + BEGIN; + RAISERROR('Valid filter types are: session, program, database, login, host', 16, 1); + RETURN; + END; + + IF @not_filter_type = 'session' AND @not_filter LIKE '%[^0123456789]%' + BEGIN; + RAISERROR('Session filters must be valid integers', 16, 1); + RETURN; + END; + + IF @show_sleeping_spids NOT IN (0, 1, 2) + BEGIN; + RAISERROR('Valid values for @show_sleeping_spids are: 0, 1, or 2', 16, 1); + RETURN; + END; + + IF @get_plans NOT IN (0, 1, 2) + BEGIN; + RAISERROR('Valid values for @get_plans are: 0, 1, or 2', 16, 1); + RETURN; + END; + + IF @get_task_info NOT IN (0, 1, 2) + BEGIN; + RAISERROR('Valid values for @get_task_info are: 0, 1, or 2', 16, 1); + RETURN; + END; + + IF @format_output NOT IN (0, 1, 2) + BEGIN; + RAISERROR('Valid values for @format_output are: 0, 1, or 2', 16, 1); + RETURN; + END; + + IF @get_memory_info = 1 AND NOT EXISTS (SELECT * FROM sys.all_objects WHERE name = 'resource_governor_resource_pools') + BEGIN; + RAISERROR('@get_memory_info is not available for SQL Server 2005.', 16, 1); + RETURN; + END; + + IF @help = 1 + BEGIN; + DECLARE + @header VARCHAR(MAX), + @params VARCHAR(MAX), + @outputs VARCHAR(MAX); + + SELECT + @header = + REPLACE + ( + REPLACE + ( + CONVERT + ( + VARCHAR(MAX), + SUBSTRING + ( + t.text, + CHARINDEX('/' + REPLICATE('*', 93), t.text) + 94, + CHARINDEX(REPLICATE('*', 93) + '/', t.text) - (CHARINDEX('/' + REPLICATE('*', 93), t.text) + 94) + ) + ), + CHAR(13)+CHAR(10), + CHAR(13) + ), + ' ', + '' + ), + @params = + CHAR(13) + + REPLACE + ( + REPLACE + ( + CONVERT + ( + VARCHAR(MAX), + SUBSTRING + ( + t.text, + CHARINDEX('--~', t.text) + 5, + CHARINDEX('--~', t.text, CHARINDEX('--~', t.text) + 5) - (CHARINDEX('--~', t.text) + 5) + ) + ), + CHAR(13)+CHAR(10), + CHAR(13) + ), + ' ', + '' + ), + @outputs = + CHAR(13) + + REPLACE + ( + REPLACE + ( + REPLACE + ( + CONVERT + ( + VARCHAR(MAX), + SUBSTRING + ( + t.text, + CHARINDEX('OUTPUT COLUMNS'+CHAR(13)+CHAR(10)+'--------------', t.text) + 32, + CHARINDEX('*/', t.text, CHARINDEX('OUTPUT COLUMNS'+CHAR(13)+CHAR(10)+'--------------', t.text) + 32) - (CHARINDEX('OUTPUT COLUMNS'+CHAR(13)+CHAR(10)+'--------------', t.text) + 32) + ) + ), + ' ', + CHAR(255) + ), + CHAR(13)+CHAR(10), + CHAR(13) + ), + ' ', + '' + ) + + CHAR(13) + FROM sys.dm_exec_requests AS r + CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t + WHERE + r.session_id = @@SPID; + + WITH + a0 AS + (SELECT 1 AS n UNION ALL SELECT 1), + a1 AS + (SELECT 1 AS n FROM a0 AS a CROSS JOIN a0 AS b), + a2 AS + (SELECT 1 AS n FROM a1 AS a CROSS JOIN a1 AS b), + a3 AS + (SELECT 1 AS n FROM a2 AS a CROSS JOIN a2 AS b), + a4 AS + (SELECT 1 AS n FROM a3 AS a CROSS JOIN a3 AS b), + numbers AS + ( + SELECT TOP(LEN(@header) - 1) + ROW_NUMBER() OVER + ( + ORDER BY (SELECT NULL) + ) AS number + FROM a4 + ORDER BY + number + ) + SELECT + RTRIM(LTRIM( + SUBSTRING + ( + @header, + number + 1, + CHARINDEX(CHAR(13), @header, number + 1) - number - 1 + ) + )) AS [------header---------------------------------------------------------------------------------------------------------------] + FROM numbers + WHERE + SUBSTRING(@header, number, 1) = CHAR(13); + + WITH + a0 AS + (SELECT 1 AS n UNION ALL SELECT 1), + a1 AS + (SELECT 1 AS n FROM a0 AS a CROSS JOIN a0 AS b), + a2 AS + (SELECT 1 AS n FROM a1 AS a CROSS JOIN a1 AS b), + a3 AS + (SELECT 1 AS n FROM a2 AS a CROSS JOIN a2 AS b), + a4 AS + (SELECT 1 AS n FROM a3 AS a CROSS JOIN a3 AS b), + numbers AS + ( + SELECT TOP(LEN(@params) - 1) + ROW_NUMBER() OVER + ( + ORDER BY (SELECT NULL) + ) AS number + FROM a4 + ORDER BY + number + ), + tokens AS + ( + SELECT + RTRIM(LTRIM( + SUBSTRING + ( + @params, + number + 1, + CHARINDEX(CHAR(13), @params, number + 1) - number - 1 + ) + )) AS token, + number, + CASE + WHEN SUBSTRING(@params, number + 1, 1) = CHAR(13) THEN number + ELSE COALESCE(NULLIF(CHARINDEX(',' + CHAR(13) + CHAR(13), @params, number), 0), LEN(@params)) + END AS param_group, + ROW_NUMBER() OVER + ( + PARTITION BY + CHARINDEX(',' + CHAR(13) + CHAR(13), @params, number), + SUBSTRING(@params, number+1, 1) + ORDER BY + number + ) AS group_order + FROM numbers + WHERE + SUBSTRING(@params, number, 1) = CHAR(13) + ), + parsed_tokens AS + ( + SELECT + MIN + ( + CASE + WHEN token LIKE '@%' THEN token + ELSE NULL + END + ) AS parameter, + MIN + ( + CASE + WHEN token LIKE '--%' THEN RIGHT(token, LEN(token) - 2) + ELSE NULL + END + ) AS description, + param_group, + group_order + FROM tokens + WHERE + NOT + ( + token = '' + AND group_order > 1 + ) + GROUP BY + param_group, + group_order + ) + SELECT + CASE + WHEN description IS NULL AND parameter IS NULL THEN '-------------------------------------------------------------------------' + WHEN param_group = MAX(param_group) OVER() THEN parameter + ELSE COALESCE(LEFT(parameter, LEN(parameter) - 1), '') + END AS [------parameter----------------------------------------------------------], + CASE + WHEN description IS NULL AND parameter IS NULL THEN '----------------------------------------------------------------------------------------------------------------------' + ELSE COALESCE(description, '') + END AS [------description-----------------------------------------------------------------------------------------------------] + FROM parsed_tokens + ORDER BY + param_group, + group_order; + + WITH + a0 AS + (SELECT 1 AS n UNION ALL SELECT 1), + a1 AS + (SELECT 1 AS n FROM a0 AS a CROSS JOIN a0 AS b), + a2 AS + (SELECT 1 AS n FROM a1 AS a CROSS JOIN a1 AS b), + a3 AS + (SELECT 1 AS n FROM a2 AS a CROSS JOIN a2 AS b), + a4 AS + (SELECT 1 AS n FROM a3 AS a CROSS JOIN a3 AS b), + numbers AS + ( + SELECT TOP(LEN(@outputs) - 1) + ROW_NUMBER() OVER + ( + ORDER BY (SELECT NULL) + ) AS number + FROM a4 + ORDER BY + number + ), + tokens AS + ( + SELECT + RTRIM(LTRIM( + SUBSTRING + ( + @outputs, + number + 1, + CASE + WHEN + COALESCE(NULLIF(CHARINDEX(CHAR(13) + 'Formatted', @outputs, number + 1), 0), LEN(@outputs)) < + COALESCE(NULLIF(CHARINDEX(CHAR(13) + CHAR(255) COLLATE Latin1_General_Bin2, @outputs, number + 1), 0), LEN(@outputs)) + THEN COALESCE(NULLIF(CHARINDEX(CHAR(13) + 'Formatted', @outputs, number + 1), 0), LEN(@outputs)) - number - 1 + ELSE + COALESCE(NULLIF(CHARINDEX(CHAR(13) + CHAR(255) COLLATE Latin1_General_Bin2, @outputs, number + 1), 0), LEN(@outputs)) - number - 1 + END + ) + )) AS token, + number, + COALESCE(NULLIF(CHARINDEX(CHAR(13) + 'Formatted', @outputs, number + 1), 0), LEN(@outputs)) AS output_group, + ROW_NUMBER() OVER + ( + PARTITION BY + COALESCE(NULLIF(CHARINDEX(CHAR(13) + 'Formatted', @outputs, number + 1), 0), LEN(@outputs)) + ORDER BY + number + ) AS output_group_order + FROM numbers + WHERE + SUBSTRING(@outputs, number, 10) = CHAR(13) + 'Formatted' + OR SUBSTRING(@outputs, number, 2) = CHAR(13) + CHAR(255) COLLATE Latin1_General_Bin2 + ), + output_tokens AS + ( + SELECT + *, + CASE output_group_order + WHEN 2 THEN MAX(CASE output_group_order WHEN 1 THEN token ELSE NULL END) OVER (PARTITION BY output_group) + ELSE '' + END COLLATE Latin1_General_Bin2 AS column_info + FROM tokens + ) + SELECT + CASE output_group_order + WHEN 1 THEN '-----------------------------------' + WHEN 2 THEN + CASE + WHEN CHARINDEX('Formatted/Non:', column_info) = 1 THEN + SUBSTRING(column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info)+1, CHARINDEX(']', column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info)+2) - CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info)) + ELSE + SUBSTRING(column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info)+2, CHARINDEX(']', column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info)+2) - CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info)-1) + END + ELSE '' + END AS formatted_column_name, + CASE output_group_order + WHEN 1 THEN '-----------------------------------' + WHEN 2 THEN + CASE + WHEN CHARINDEX('Formatted/Non:', column_info) = 1 THEN + SUBSTRING(column_info, CHARINDEX(']', column_info)+2, LEN(column_info)) + ELSE + SUBSTRING(column_info, CHARINDEX(']', column_info)+2, CHARINDEX('Non-Formatted:', column_info, CHARINDEX(']', column_info)+2) - CHARINDEX(']', column_info)-3) + END + ELSE '' + END AS formatted_column_type, + CASE output_group_order + WHEN 1 THEN '---------------------------------------' + WHEN 2 THEN + CASE + WHEN CHARINDEX('Formatted/Non:', column_info) = 1 THEN '' + ELSE + CASE + WHEN SUBSTRING(column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))+1, 1) = '<' THEN + SUBSTRING(column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))+1, CHARINDEX('>', column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))+1) - CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))) + ELSE + SUBSTRING(column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))+1, CHARINDEX(']', column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))+1) - CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))) + END + END + ELSE '' + END AS unformatted_column_name, + CASE output_group_order + WHEN 1 THEN '---------------------------------------' + WHEN 2 THEN + CASE + WHEN CHARINDEX('Formatted/Non:', column_info) = 1 THEN '' + ELSE + CASE + WHEN SUBSTRING(column_info, CHARINDEX(CHAR(255) COLLATE Latin1_General_Bin2, column_info, CHARINDEX('Non-Formatted:', column_info))+1, 1) = '<' THEN '' + ELSE + SUBSTRING(column_info, CHARINDEX(']', column_info, CHARINDEX('Non-Formatted:', column_info))+2, CHARINDEX('Non-Formatted:', column_info, CHARINDEX(']', column_info)+2) - CHARINDEX(']', column_info)-3) + END + END + ELSE '' + END AS unformatted_column_type, + CASE output_group_order + WHEN 1 THEN '----------------------------------------------------------------------------------------------------------------------' + ELSE REPLACE(token, CHAR(255) COLLATE Latin1_General_Bin2, '') + END AS [------description-----------------------------------------------------------------------------------------------------] + FROM output_tokens + WHERE + NOT + ( + output_group_order = 1 + AND output_group = LEN(@outputs) + ) + ORDER BY + output_group, + CASE output_group_order + WHEN 1 THEN 99 + ELSE output_group_order + END; + + RETURN; + END; + + WITH + a0 AS + (SELECT 1 AS n UNION ALL SELECT 1), + a1 AS + (SELECT 1 AS n FROM a0 AS a CROSS JOIN a0 AS b), + a2 AS + (SELECT 1 AS n FROM a1 AS a CROSS JOIN a1 AS b), + a3 AS + (SELECT 1 AS n FROM a2 AS a CROSS JOIN a2 AS b), + a4 AS + (SELECT 1 AS n FROM a3 AS a CROSS JOIN a3 AS b), + numbers AS + ( + SELECT TOP(LEN(@output_column_list)) + ROW_NUMBER() OVER + ( + ORDER BY (SELECT NULL) + ) AS number + FROM a4 + ORDER BY + number + ), + tokens AS + ( + SELECT + '|[' + + SUBSTRING + ( + @output_column_list, + number + 1, + CHARINDEX(']', @output_column_list, number) - number - 1 + ) + '|]' AS token, + number + FROM numbers + WHERE + SUBSTRING(@output_column_list, number, 1) = '[' + ), + ordered_columns AS + ( + SELECT + x.column_name, + ROW_NUMBER() OVER + ( + PARTITION BY + x.column_name + ORDER BY + tokens.number, + x.default_order + ) AS r, + ROW_NUMBER() OVER + ( + ORDER BY + tokens.number, + x.default_order + ) AS s + FROM tokens + JOIN + ( + SELECT '[session_id]' AS column_name, 1 AS default_order + UNION ALL + SELECT '[dd hh:mm:ss.mss]', 2 + WHERE + @format_output IN (1, 2) + UNION ALL + SELECT '[dd hh:mm:ss.mss (avg)]', 3 + WHERE + @format_output IN (1, 2) + AND @get_avg_time = 1 + UNION ALL + SELECT '[avg_elapsed_time]', 4 + WHERE + @format_output = 0 + AND @get_avg_time = 1 + UNION ALL + SELECT '[physical_io]', 5 + WHERE + @get_task_info = 2 + UNION ALL + SELECT '[reads]', 6 + UNION ALL + SELECT '[physical_reads]', 7 + UNION ALL + SELECT '[writes]', 8 + UNION ALL + SELECT '[tempdb_allocations]', 9 + UNION ALL + SELECT '[tempdb_current]', 10 + UNION ALL + SELECT '[CPU]', 11 + UNION ALL + SELECT '[context_switches]', 12 + WHERE + @get_task_info = 2 + UNION ALL + SELECT '[used_memory]', 13 + UNION ALL + SELECT '[max_used_memory]', 14 + WHERE + @get_memory_info = 1 + UNION ALL + SELECT '[requested_memory]', 15 + WHERE + @get_memory_info = 1 + UNION ALL + SELECT '[granted_memory]', 16 + WHERE + @get_memory_info = 1 + UNION ALL + SELECT '[physical_io_delta]', 17 + WHERE + @delta_interval > 0 + AND @get_task_info = 2 + UNION ALL + SELECT '[reads_delta]', 18 + WHERE + @delta_interval > 0 + UNION ALL + SELECT '[physical_reads_delta]', 19 + WHERE + @delta_interval > 0 + UNION ALL + SELECT '[writes_delta]', 20 + WHERE + @delta_interval > 0 + UNION ALL + SELECT '[tempdb_allocations_delta]', 21 + WHERE + @delta_interval > 0 + UNION ALL + SELECT '[tempdb_current_delta]', 22 + WHERE + @delta_interval > 0 + UNION ALL + SELECT '[CPU_delta]', 23 + WHERE + @delta_interval > 0 + UNION ALL + SELECT '[context_switches_delta]', 24 + WHERE + @delta_interval > 0 + AND @get_task_info = 2 + UNION ALL + SELECT '[used_memory_delta]', 25 + WHERE + @delta_interval > 0 + UNION ALL + SELECT '[max_used_memory_delta]', 26 + WHERE + @delta_interval > 0 + AND @get_memory_info = 1 + UNION ALL + SELECT '[tasks]', 27 + WHERE + @get_task_info = 2 + UNION ALL + SELECT '[status]', 28 + UNION ALL + SELECT '[wait_info]', 29 + WHERE + @get_task_info > 0 + OR @find_block_leaders = 1 + UNION ALL + SELECT '[locks]', 30 + WHERE + @get_locks = 1 + UNION ALL + SELECT '[tran_start_time]', 31 + WHERE + @get_transaction_info = 1 + UNION ALL + SELECT '[tran_log_writes]', 32 + WHERE + @get_transaction_info = 1 + UNION ALL + SELECT '[implicit_tran]', 33 + WHERE + @get_transaction_info = 1 + UNION ALL + SELECT '[open_tran_count]', 34 + UNION ALL + SELECT '[sql_command]', 35 + WHERE + @get_outer_command = 1 + UNION ALL + SELECT '[sql_text]', 36 + UNION ALL + SELECT '[query_plan]', 37 + WHERE + @get_plans >= 1 + UNION ALL + SELECT '[blocking_session_id]', 38 + WHERE + @get_task_info > 0 + OR @find_block_leaders = 1 + UNION ALL + SELECT '[blocked_session_count]', 39 + WHERE + @find_block_leaders = 1 + UNION ALL + SELECT '[percent_complete]', 40 + UNION ALL + SELECT '[host_name]', 41 + UNION ALL + SELECT '[login_name]', 42 + UNION ALL + SELECT '[database_name]', 43 + UNION ALL + SELECT '[program_name]', 44 + UNION ALL + SELECT '[additional_info]', 45 + WHERE + @get_additional_info = 1 + UNION ALL + SELECT '[memory_info]', 46 + WHERE + @get_memory_info = 1 + UNION ALL + SELECT '[start_time]', 47 + UNION ALL + SELECT '[login_time]', 48 + UNION ALL + SELECT '[request_id]', 49 + UNION ALL + SELECT '[collection_time]', 50 + ) AS x ON + x.column_name LIKE token ESCAPE '|' + ) + SELECT + @output_column_list = + STUFF + ( + ( + SELECT + ',' + column_name as [text()] + FROM ordered_columns + WHERE + r = 1 + ORDER BY + s + FOR XML + PATH('') + ), + 1, + 1, + '' + ); + + IF COALESCE(RTRIM(@output_column_list), '') = '' + BEGIN; + RAISERROR('No valid column matches found in @output_column_list or no columns remain due to selected options.', 16, 1); + RETURN; + END; + + IF @destination_table <> '' + BEGIN; + SET @destination_table = + --database + COALESCE(QUOTENAME(PARSENAME(@destination_table, 3)) + '.', '') + + --schema + COALESCE(QUOTENAME(PARSENAME(@destination_table, 2)) + '.', '') + + --table + COALESCE(QUOTENAME(PARSENAME(@destination_table, 1)), ''); + + IF COALESCE(RTRIM(@destination_table), '') = '' + BEGIN; + RAISERROR('Destination table not properly formatted.', 16, 1); + RETURN; + END; + END; + + WITH + a0 AS + (SELECT 1 AS n UNION ALL SELECT 1), + a1 AS + (SELECT 1 AS n FROM a0 AS a CROSS JOIN a0 AS b), + a2 AS + (SELECT 1 AS n FROM a1 AS a CROSS JOIN a1 AS b), + a3 AS + (SELECT 1 AS n FROM a2 AS a CROSS JOIN a2 AS b), + a4 AS + (SELECT 1 AS n FROM a3 AS a CROSS JOIN a3 AS b), + numbers AS + ( + SELECT TOP(LEN(@sort_order)) + ROW_NUMBER() OVER + ( + ORDER BY (SELECT NULL) + ) AS number + FROM a4 + ORDER BY + number + ), + tokens AS + ( + SELECT + '|[' + + SUBSTRING + ( + @sort_order, + number + 1, + CHARINDEX(']', @sort_order, number) - number - 1 + ) + '|]' AS token, + SUBSTRING + ( + @sort_order, + CHARINDEX(']', @sort_order, number) + 1, + COALESCE(NULLIF(CHARINDEX('[', @sort_order, CHARINDEX(']', @sort_order, number)), 0), LEN(@sort_order)) - CHARINDEX(']', @sort_order, number) + ) AS next_chunk, + number + FROM numbers + WHERE + SUBSTRING(@sort_order, number, 1) = '[' + ), + ordered_columns AS + ( + SELECT + x.column_name + + CASE + WHEN LOWER(tokens.next_chunk) LIKE '%asc%' THEN ' ASC' + WHEN LOWER(tokens.next_chunk) LIKE '%desc%' THEN ' DESC' + ELSE '' + END AS column_name, + ROW_NUMBER() OVER + ( + PARTITION BY + x.column_name + ORDER BY + tokens.number + ) AS r, + tokens.number + FROM tokens + JOIN + ( + SELECT '[session_id]' AS column_name + UNION ALL + SELECT '[physical_io]' + UNION ALL + SELECT '[reads]' + UNION ALL + SELECT '[physical_reads]' + UNION ALL + SELECT '[writes]' + UNION ALL + SELECT '[tempdb_allocations]' + UNION ALL + SELECT '[tempdb_current]' + UNION ALL + SELECT '[CPU]' + UNION ALL + SELECT '[context_switches]' + UNION ALL + SELECT '[used_memory]' + UNION ALL + SELECT '[max_used_memory]' + UNION ALL + SELECT '[requested_memory]' + UNION ALL + SELECT '[granted_memory]' + UNION ALL + SELECT '[physical_io_delta]' + UNION ALL + SELECT '[reads_delta]' + UNION ALL + SELECT '[physical_reads_delta]' + UNION ALL + SELECT '[writes_delta]' + UNION ALL + SELECT '[tempdb_allocations_delta]' + UNION ALL + SELECT '[tempdb_current_delta]' + UNION ALL + SELECT '[CPU_delta]' + UNION ALL + SELECT '[context_switches_delta]' + UNION ALL + SELECT '[used_memory_delta]' + UNION ALL + SELECT '[max_used_memory_delta]' + UNION ALL + SELECT '[tasks]' + UNION ALL + SELECT '[tran_start_time]' + UNION ALL + SELECT '[open_tran_count]' + UNION ALL + SELECT '[blocking_session_id]' + UNION ALL + SELECT '[blocked_session_count]' + UNION ALL + SELECT '[percent_complete]' + UNION ALL + SELECT '[host_name]' + UNION ALL + SELECT '[login_name]' + UNION ALL + SELECT '[database_name]' + UNION ALL + SELECT '[start_time]' + UNION ALL + SELECT '[login_time]' + UNION ALL + SELECT '[program_name]' + ) AS x ON + x.column_name LIKE token ESCAPE '|' + ) + SELECT + @sort_order = COALESCE(z.sort_order, '') + FROM + ( + SELECT + STUFF + ( + ( + SELECT + ',' + column_name as [text()] + FROM ordered_columns + WHERE + r = 1 + ORDER BY + number + FOR XML + PATH('') + ), + 1, + 1, + '' + ) AS sort_order + ) AS z; + + CREATE TABLE #sessions + ( + recursion SMALLINT NOT NULL, + session_id SMALLINT NOT NULL, + request_id INT NOT NULL, + session_number INT NOT NULL, + elapsed_time INT NOT NULL, + avg_elapsed_time INT NULL, + physical_io BIGINT NULL, + reads BIGINT NULL, + physical_reads BIGINT NULL, + writes BIGINT NULL, + tempdb_allocations BIGINT NULL, + tempdb_current BIGINT NULL, + CPU BIGINT NULL, + thread_CPU_snapshot BIGINT NULL, + context_switches BIGINT NULL, + used_memory BIGINT NOT NULL, + max_used_memory BIGINT NULL, + requested_memory BIGINT NULL, + granted_memory BIGINT NULL, + tasks SMALLINT NULL, + status VARCHAR(30) NOT NULL, + wait_info NVARCHAR(4000) NULL, + locks XML NULL, + transaction_id BIGINT NULL, + tran_start_time DATETIME NULL, + tran_log_writes NVARCHAR(4000) NULL, + implicit_tran NVARCHAR(3) NULL, + open_tran_count SMALLINT NULL, + sql_command XML NULL, + sql_handle VARBINARY(64) NULL, + statement_start_offset INT NULL, + statement_end_offset INT NULL, + sql_text XML NULL, + plan_handle VARBINARY(64) NULL, + query_plan XML NULL, + blocking_session_id SMALLINT NULL, + blocked_session_count SMALLINT NULL, + percent_complete REAL NULL, + host_name sysname NULL, + login_name sysname NOT NULL, + database_name sysname NULL, + program_name sysname NULL, + additional_info XML NULL, + memory_info XML NULL, + start_time DATETIME NOT NULL, + login_time DATETIME NULL, + last_request_start_time DATETIME NULL, + PRIMARY KEY CLUSTERED (session_id, request_id, recursion) WITH (IGNORE_DUP_KEY = ON), + UNIQUE NONCLUSTERED (transaction_id, session_id, request_id, recursion) WITH (IGNORE_DUP_KEY = ON) + ); + + IF @return_schema = 0 + BEGIN; + --Disable unnecessary autostats on the table + CREATE STATISTICS s_session_id ON #sessions (session_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_request_id ON #sessions (request_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_transaction_id ON #sessions (transaction_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_session_number ON #sessions (session_number) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_status ON #sessions (status) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_start_time ON #sessions (start_time) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_last_request_start_time ON #sessions (last_request_start_time) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_recursion ON #sessions (recursion) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + + DECLARE @recursion SMALLINT; + SET @recursion = + CASE @delta_interval + WHEN 0 THEN 1 + ELSE -1 + END; + + DECLARE @first_collection_ms_ticks BIGINT; + DECLARE @last_collection_start DATETIME; + DECLARE @sys_info BIT; + SET @sys_info = ISNULL(CONVERT(BIT, SIGN(OBJECT_ID('sys.dm_os_sys_info'))), 0); + + --Used for the delta pull + REDO:; + + IF + @get_locks = 1 + AND @recursion = 1 + AND @output_column_list LIKE '%|[locks|]%' ESCAPE '|' + BEGIN; + SELECT + y.resource_type, + y.database_name, + y.object_id, + y.file_id, + y.page_type, + y.hobt_id, + y.allocation_unit_id, + y.index_id, + y.schema_id, + y.principal_id, + y.request_mode, + y.request_status, + y.session_id, + y.resource_description, + y.request_count, + s.request_id, + s.start_time, + CONVERT(sysname, NULL) AS object_name, + CONVERT(sysname, NULL) AS index_name, + CONVERT(sysname, NULL) AS schema_name, + CONVERT(sysname, NULL) AS principal_name, + CONVERT(NVARCHAR(2048), NULL) AS query_error + INTO #locks + FROM + ( + SELECT + sp.spid AS session_id, + CASE sp.status + WHEN 'sleeping' THEN CONVERT(INT, 0) + ELSE sp.request_id + END AS request_id, + CASE sp.status + WHEN 'sleeping' THEN sp.last_batch + ELSE COALESCE(req.start_time, sp.last_batch) + END AS start_time, + sp.dbid + FROM sys.sysprocesses AS sp + OUTER APPLY + ( + SELECT TOP(1) + CASE + WHEN + ( + sp.hostprocess > '' + OR r.total_elapsed_time < 0 + ) THEN + r.start_time + ELSE + DATEADD + ( + ms, + 1000 * (DATEPART(ms, DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE())) / 500) - DATEPART(ms, DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE())), + DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE()) + ) + END AS start_time + FROM sys.dm_exec_requests AS r + WHERE + r.session_id = sp.spid + AND r.request_id = sp.request_id + ) AS req + WHERE + --Process inclusive filter + 1 = + CASE + WHEN @filter <> '' THEN + CASE @filter_type + WHEN 'session' THEN + CASE + WHEN + CONVERT(SMALLINT, @filter) = 0 + OR sp.spid = CONVERT(SMALLINT, @filter) + THEN 1 + ELSE 0 + END + WHEN 'program' THEN + CASE + WHEN sp.program_name LIKE @filter THEN 1 + ELSE 0 + END + WHEN 'login' THEN + CASE + WHEN sp.loginame LIKE @filter THEN 1 + ELSE 0 + END + WHEN 'host' THEN + CASE + WHEN sp.hostname LIKE @filter THEN 1 + ELSE 0 + END + WHEN 'database' THEN + CASE + WHEN DB_NAME(sp.dbid) LIKE @filter THEN 1 + ELSE 0 + END + ELSE 0 + END + ELSE 1 + END + --Process exclusive filter + AND 0 = + CASE + WHEN @not_filter <> '' THEN + CASE @not_filter_type + WHEN 'session' THEN + CASE + WHEN sp.spid = CONVERT(SMALLINT, @not_filter) THEN 1 + ELSE 0 + END + WHEN 'program' THEN + CASE + WHEN sp.program_name LIKE @not_filter THEN 1 + ELSE 0 + END + WHEN 'login' THEN + CASE + WHEN sp.loginame LIKE @not_filter THEN 1 + ELSE 0 + END + WHEN 'host' THEN + CASE + WHEN sp.hostname LIKE @not_filter THEN 1 + ELSE 0 + END + WHEN 'database' THEN + CASE + WHEN DB_NAME(sp.dbid) LIKE @not_filter THEN 1 + ELSE 0 + END + ELSE 0 + END + ELSE 0 + END + AND + ( + @show_own_spid = 1 + OR sp.spid <> @@SPID + ) + AND + ( + @show_system_spids = 1 + OR sp.hostprocess > '' + ) + AND sp.ecid = 0 + ) AS s + INNER HASH JOIN + ( + SELECT + x.resource_type, + x.database_name, + x.object_id, + x.file_id, + CASE + WHEN x.page_no = 1 OR x.page_no % 8088 = 0 THEN 'PFS' + WHEN x.page_no = 2 OR x.page_no % 511232 = 0 THEN 'GAM' + WHEN x.page_no = 3 OR (x.page_no - 1) % 511232 = 0 THEN 'SGAM' + WHEN x.page_no = 6 OR (x.page_no - 6) % 511232 = 0 THEN 'DCM' + WHEN x.page_no = 7 OR (x.page_no - 7) % 511232 = 0 THEN 'BCM' + WHEN x.page_no IS NOT NULL THEN '*' + ELSE NULL + END AS page_type, + x.hobt_id, + x.allocation_unit_id, + x.index_id, + x.schema_id, + x.principal_id, + x.request_mode, + x.request_status, + x.session_id, + x.request_id, + CASE + WHEN COALESCE(x.object_id, x.file_id, x.hobt_id, x.allocation_unit_id, x.index_id, x.schema_id, x.principal_id) IS NULL THEN NULLIF(resource_description, '') + ELSE NULL + END AS resource_description, + COUNT(*) AS request_count + FROM + ( + SELECT + tl.resource_type + + CASE + WHEN tl.resource_subtype = '' THEN '' + ELSE '.' + tl.resource_subtype + END AS resource_type, + COALESCE(DB_NAME(tl.resource_database_id), N'(null)') AS database_name, + CONVERT + ( + INT, + CASE + WHEN tl.resource_type = 'OBJECT' THEN tl.resource_associated_entity_id + WHEN tl.resource_description LIKE '%object_id = %' THEN + ( + SUBSTRING + ( + tl.resource_description, + (CHARINDEX('object_id = ', tl.resource_description) + 12), + COALESCE + ( + NULLIF + ( + CHARINDEX(',', tl.resource_description, CHARINDEX('object_id = ', tl.resource_description) + 12), + 0 + ), + DATALENGTH(tl.resource_description)+1 + ) - (CHARINDEX('object_id = ', tl.resource_description) + 12) + ) + ) + ELSE NULL + END + ) AS object_id, + CONVERT + ( + INT, + CASE + WHEN tl.resource_type = 'FILE' THEN CONVERT(INT, tl.resource_description) + WHEN tl.resource_type IN ('PAGE', 'EXTENT', 'RID') THEN LEFT(tl.resource_description, CHARINDEX(':', tl.resource_description)-1) + ELSE NULL + END + ) AS file_id, + CONVERT + ( + INT, + CASE + WHEN tl.resource_type IN ('PAGE', 'EXTENT', 'RID') THEN + SUBSTRING + ( + tl.resource_description, + CHARINDEX(':', tl.resource_description) + 1, + COALESCE + ( + NULLIF + ( + CHARINDEX(':', tl.resource_description, CHARINDEX(':', tl.resource_description) + 1), + 0 + ), + DATALENGTH(tl.resource_description)+1 + ) - (CHARINDEX(':', tl.resource_description) + 1) + ) + ELSE NULL + END + ) AS page_no, + CASE + WHEN tl.resource_type IN ('PAGE', 'KEY', 'RID', 'HOBT') THEN tl.resource_associated_entity_id + ELSE NULL + END AS hobt_id, + CASE + WHEN tl.resource_type = 'ALLOCATION_UNIT' THEN tl.resource_associated_entity_id + ELSE NULL + END AS allocation_unit_id, + CONVERT + ( + INT, + CASE + WHEN + /*TODO: Deal with server principals*/ + tl.resource_subtype <> 'SERVER_PRINCIPAL' + AND tl.resource_description LIKE '%index_id or stats_id = %' THEN + ( + SUBSTRING + ( + tl.resource_description, + (CHARINDEX('index_id or stats_id = ', tl.resource_description) + 23), + COALESCE + ( + NULLIF + ( + CHARINDEX(',', tl.resource_description, CHARINDEX('index_id or stats_id = ', tl.resource_description) + 23), + 0 + ), + DATALENGTH(tl.resource_description)+1 + ) - (CHARINDEX('index_id or stats_id = ', tl.resource_description) + 23) + ) + ) + ELSE NULL + END + ) AS index_id, + CONVERT + ( + INT, + CASE + WHEN tl.resource_description LIKE '%schema_id = %' THEN + ( + SUBSTRING + ( + tl.resource_description, + (CHARINDEX('schema_id = ', tl.resource_description) + 12), + COALESCE + ( + NULLIF + ( + CHARINDEX(',', tl.resource_description, CHARINDEX('schema_id = ', tl.resource_description) + 12), + 0 + ), + DATALENGTH(tl.resource_description)+1 + ) - (CHARINDEX('schema_id = ', tl.resource_description) + 12) + ) + ) + ELSE NULL + END + ) AS schema_id, + CONVERT + ( + INT, + CASE + WHEN tl.resource_description LIKE '%principal_id = %' THEN + ( + SUBSTRING + ( + tl.resource_description, + (CHARINDEX('principal_id = ', tl.resource_description) + 15), + COALESCE + ( + NULLIF + ( + CHARINDEX(',', tl.resource_description, CHARINDEX('principal_id = ', tl.resource_description) + 15), + 0 + ), + DATALENGTH(tl.resource_description)+1 + ) - (CHARINDEX('principal_id = ', tl.resource_description) + 15) + ) + ) + ELSE NULL + END + ) AS principal_id, + tl.request_mode, + tl.request_status, + tl.request_session_id AS session_id, + tl.request_request_id AS request_id, + + /*TODO: Applocks, other resource_descriptions*/ + RTRIM(tl.resource_description) AS resource_description, + tl.resource_associated_entity_id + /*********************************************/ + FROM + ( + SELECT + request_session_id, + CONVERT(VARCHAR(120), resource_type) COLLATE Latin1_General_Bin2 AS resource_type, + CONVERT(VARCHAR(120), resource_subtype) COLLATE Latin1_General_Bin2 AS resource_subtype, + resource_database_id, + CONVERT(VARCHAR(512), resource_description) COLLATE Latin1_General_Bin2 AS resource_description, + resource_associated_entity_id, + CONVERT(VARCHAR(120), request_mode) COLLATE Latin1_General_Bin2 AS request_mode, + CONVERT(VARCHAR(120), request_status) COLLATE Latin1_General_Bin2 AS request_status, + request_request_id + FROM sys.dm_tran_locks + ) AS tl + ) AS x + GROUP BY + x.resource_type, + x.database_name, + x.object_id, + x.file_id, + CASE + WHEN x.page_no = 1 OR x.page_no % 8088 = 0 THEN 'PFS' + WHEN x.page_no = 2 OR x.page_no % 511232 = 0 THEN 'GAM' + WHEN x.page_no = 3 OR (x.page_no - 1) % 511232 = 0 THEN 'SGAM' + WHEN x.page_no = 6 OR (x.page_no - 6) % 511232 = 0 THEN 'DCM' + WHEN x.page_no = 7 OR (x.page_no - 7) % 511232 = 0 THEN 'BCM' + WHEN x.page_no IS NOT NULL THEN '*' + ELSE NULL + END, + x.hobt_id, + x.allocation_unit_id, + x.index_id, + x.schema_id, + x.principal_id, + x.request_mode, + x.request_status, + x.session_id, + x.request_id, + CASE + WHEN COALESCE(x.object_id, x.file_id, x.hobt_id, x.allocation_unit_id, x.index_id, x.schema_id, x.principal_id) IS NULL THEN NULLIF(resource_description, '') + ELSE NULL + END + ) AS y ON + y.session_id = s.session_id + AND y.request_id = s.request_id + OPTION (HASH GROUP); + + --Disable unnecessary autostats on the table + CREATE STATISTICS s_database_name ON #locks (database_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_object_id ON #locks (object_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_hobt_id ON #locks (hobt_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_allocation_unit_id ON #locks (allocation_unit_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_index_id ON #locks (index_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_schema_id ON #locks (schema_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_principal_id ON #locks (principal_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_request_id ON #locks (request_id) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_start_time ON #locks (start_time) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_resource_type ON #locks (resource_type) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_object_name ON #locks (object_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_schema_name ON #locks (schema_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_page_type ON #locks (page_type) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_request_mode ON #locks (request_mode) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_request_status ON #locks (request_status) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_resource_description ON #locks (resource_description) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_index_name ON #locks (index_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_principal_name ON #locks (principal_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + END; + + DECLARE + @sql VARCHAR(MAX), + @sql_n NVARCHAR(MAX), + @core_session_join VARCHAR(MAX); + + SET @core_session_join = + '@sessions AS sp + LEFT OUTER LOOP JOIN sys.dm_exec_sessions AS s ON + s.session_id = sp.session_id + AND s.login_time = sp.login_time + LEFT OUTER LOOP JOIN sys.dm_exec_requests AS r ON + sp.status <> ''sleeping'' + AND r.session_id = sp.session_id + AND r.request_id = sp.request_id + AND + ( + ( + s.is_user_process = 0 + AND sp.is_user_process = 0 + ) + OR + ( + r.start_time = s.last_request_start_time + AND s.last_request_end_time <= sp.last_request_end_time + ) + ) '; + + SET @sql = + CONVERT(VARCHAR(MAX), '') + + 'DECLARE @blocker BIT; + SET @blocker = 0; + DECLARE @i INT; + SET @i = 2147483647; + + DECLARE @sessions TABLE + ( + session_id SMALLINT NOT NULL, + request_id INT NOT NULL, + login_time DATETIME, + last_request_end_time DATETIME, + status VARCHAR(30), + statement_start_offset INT, + statement_end_offset INT, + sql_handle BINARY(20), + host_name NVARCHAR(128), + login_name NVARCHAR(128), + program_name NVARCHAR(128), + database_id SMALLINT, + memory_usage INT, + open_tran_count SMALLINT, + ' + + CASE + WHEN + ( + @get_task_info <> 0 + OR @find_block_leaders = 1 + ) THEN + 'wait_type NVARCHAR(32), + wait_resource NVARCHAR(256), + wait_time BIGINT, + ' + ELSE + '' + END + + 'blocked SMALLINT, + is_user_process BIT, + cmd VARCHAR(32), + PRIMARY KEY CLUSTERED (session_id, request_id) WITH (IGNORE_DUP_KEY = ON) + ); + + DECLARE @blockers TABLE + ( + session_id INT NOT NULL PRIMARY KEY WITH (IGNORE_DUP_KEY = ON) + ); + + BLOCKERS:; + + INSERT @sessions + ( + session_id, + request_id, + login_time, + last_request_end_time, + status, + statement_start_offset, + statement_end_offset, + sql_handle, + host_name, + login_name, + program_name, + database_id, + memory_usage, + open_tran_count, + ' + + CASE + WHEN + ( + @get_task_info <> 0 + OR @find_block_leaders = 1 + ) THEN + 'wait_type, + wait_resource, + wait_time, + ' + ELSE + '' + END + + 'blocked, + is_user_process, + cmd + ) + SELECT TOP(@i) + spy.session_id, + spy.request_id, + spy.login_time, + spy.last_request_end_time, + spy.status, + spy.statement_start_offset, + spy.statement_end_offset, + spy.sql_handle, + spy.host_name, + spy.login_name, + spy.program_name, + spy.database_id, + spy.memory_usage, + spy.open_tran_count, + ' + + CASE + WHEN + ( + @get_task_info <> 0 + OR @find_block_leaders = 1 + ) THEN + 'spy.wait_type, + CASE + WHEN + spy.wait_type LIKE N''PAGE%LATCH_%'' + OR spy.wait_type IN (N''CXPACKET'', N''CXCONSUMER'', N''CXSYNC_PORT'', N''CXSYNC_CONSUMER'') + OR spy.wait_type LIKE N''LATCH[_]%'' + OR spy.wait_type = N''OLEDB'' THEN + spy.wait_resource + ELSE + NULL + END AS wait_resource, + spy.wait_time, + ' + ELSE + '' + END + + 'spy.blocked, + spy.is_user_process, + spy.cmd + FROM + ( + SELECT TOP(@i) + spx.*, + ' + + CASE + WHEN + ( + @get_task_info <> 0 + OR @find_block_leaders = 1 + ) THEN + 'ROW_NUMBER() OVER + ( + PARTITION BY + spx.session_id, + spx.request_id + ORDER BY + CASE + WHEN spx.wait_type LIKE N''LCK[_]%'' THEN + 1 + ELSE + 99 + END, + spx.wait_time DESC, + spx.blocked DESC + ) AS r + ' + ELSE + '1 AS r + ' + END + + 'FROM + ( + SELECT TOP(@i) + sp0.session_id, + sp0.request_id, + sp0.login_time, + sp0.last_request_end_time, + LOWER(sp0.status) AS status, + CASE + WHEN sp0.cmd = ''CREATE INDEX'' THEN + 0 + ELSE + sp0.stmt_start + END AS statement_start_offset, + CASE + WHEN sp0.cmd = N''CREATE INDEX'' THEN + -1 + ELSE + COALESCE(NULLIF(sp0.stmt_end, 0), -1) + END AS statement_end_offset, + sp0.sql_handle, + sp0.host_name, + sp0.login_name, + sp0.program_name, + sp0.database_id, + sp0.memory_usage, + sp0.open_tran_count, + ' + + CASE + WHEN + ( + @get_task_info <> 0 + OR @find_block_leaders = 1 + ) THEN + 'CASE + WHEN sp0.wait_time > 0 AND sp0.wait_type NOT IN (N''CXPACKET'', N''CXCONSUMER'', N''CXSYNC_PORT'', N''CXSYNC_CONSUMER'') THEN + sp0.wait_type + ELSE + NULL + END AS wait_type, + CASE + WHEN sp0.wait_time > 0 AND sp0.wait_type NOT IN (N''CXPACKET'', N''CXCONSUMER'', N''CXSYNC_PORT'', N''CXSYNC_CONSUMER'') THEN + sp0.wait_resource + ELSE + NULL + END AS wait_resource, + CASE + WHEN sp0.wait_type NOT IN (N''CXPACKET'', N''CXCONSUMER'', N''CXSYNC_PORT'', N''CXSYNC_CONSUMER'') THEN + sp0.wait_time + ELSE + 0 + END AS wait_time, + ' + ELSE + '' + END + + 'sp0.blocked, + sp0.is_user_process, + sp0.cmd + FROM + ( + SELECT TOP(@i) + sp1.session_id, + sp1.request_id, + sp1.login_time, + sp1.last_request_end_time, + sp1.status, + sp1.cmd, + sp1.stmt_start, + sp1.stmt_end, + MAX(NULLIF(sp1.sql_handle, 0x00)) OVER (PARTITION BY sp1.session_id, sp1.request_id) AS sql_handle, + sp1.host_name, + MAX(sp1.login_name) OVER (PARTITION BY sp1.session_id, sp1.request_id) AS login_name, + sp1.program_name, + sp1.database_id, + MAX(sp1.memory_usage) OVER (PARTITION BY sp1.session_id, sp1.request_id) AS memory_usage, + MAX(sp1.open_tran_count) OVER (PARTITION BY sp1.session_id, sp1.request_id) AS open_tran_count, + sp1.wait_type, + sp1.wait_resource, + sp1.wait_time, + sp1.blocked, + sp1.hostprocess, + sp1.is_user_process + FROM + ( + SELECT TOP(@i) + sp2.spid AS session_id, + v2.request_id, + MAX(sp2.login_time) AS login_time, + MAX(sp2.last_batch) AS last_request_end_time, + MAX(CONVERT(VARCHAR(30), RTRIM(sp2.status)) COLLATE Latin1_General_Bin2) AS status, + MAX(CONVERT(VARCHAR(32), RTRIM(sp2.cmd)) COLLATE Latin1_General_Bin2) AS cmd, + MAX(sp2.stmt_start) AS stmt_start, + MAX(sp2.stmt_end) AS stmt_end, + MAX(sp2.sql_handle) AS sql_handle, + MAX(CONVERT(sysname, RTRIM(sp2.hostname)) COLLATE SQL_Latin1_General_CP1_CI_AS) AS host_name, + MAX(CONVERT(sysname, RTRIM(sp2.loginame)) COLLATE SQL_Latin1_General_CP1_CI_AS) AS login_name, + MAX + ( + CASE + WHEN blk.queue_id IS NOT NULL THEN + N''Service Broker + database_id: '' + CONVERT(NVARCHAR, blk.database_id) + + N'' queue_id: '' + CONVERT(NVARCHAR, blk.queue_id) + ELSE + CONVERT + ( + sysname, + RTRIM(sp2.program_name) + ) + END COLLATE SQL_Latin1_General_CP1_CI_AS + ) AS program_name, + MAX(sp2.dbid) AS database_id, + MAX(sp2.memusage) AS memory_usage, + MAX(sp2.open_tran) AS open_tran_count, + RTRIM(sp2.lastwaittype) AS wait_type, + v2.wait_resource, + MAX(sp2.waittime) AS wait_time, + COALESCE(NULLIF(sp2.blocked, sp2.spid), 0) AS blocked, + MAX + ( + CASE + WHEN blk.session_id = sp2.spid THEN + ''blocker'' + ELSE + RTRIM(sp2.hostprocess) + END + ) AS hostprocess, + CONVERT + ( + BIT, + MAX + ( + CASE + WHEN sp2.hostprocess > '''' THEN + 1 + ELSE + 0 + END + ) + ) AS is_user_process + FROM + ( + SELECT TOP(@i) + session_id, + CONVERT(INT, NULL) AS queue_id, + CONVERT(INT, NULL) AS database_id + FROM @blockers + + UNION ALL + + SELECT TOP(@i) + CONVERT(SMALLINT, 0), + CONVERT(INT, NULL) AS queue_id, + CONVERT(INT, NULL) AS database_id + WHERE + @blocker = 0 + + UNION ALL + + SELECT TOP(@i) + CONVERT(SMALLINT, spid), + queue_id, + database_id + FROM sys.dm_broker_activated_tasks + WHERE + @blocker = 0 + ) AS blk + INNER JOIN sys.sysprocesses AS sp2 ON + sp2.spid = blk.session_id + OR + ( + blk.session_id = 0 + AND @blocker = 0 + ) + CROSS APPLY + ( + SELECT + CASE sp2.status + WHEN ''sleeping'' THEN + CONVERT(INT, 0) + ELSE + sp2.request_id + END AS request_id, + RTRIM + ( + LEFT + ( + sp2.waitresource COLLATE Latin1_General_Bin2, + ISNULL(NULLIF(CHARINDEX('' (LATCH '', sp2.waitresource COLLATE Latin1_General_Bin2) - 1, -1), 256) + ) + ) AS wait_resource + ) AS v2 + ' + + CASE + WHEN + ( + @get_task_info = 0 + AND @find_block_leaders = 0 + ) THEN + 'WHERE + sp2.ecid = 0 + ' + ELSE + '' + END + + 'GROUP BY + sp2.spid, + v2.request_id, + RTRIM(sp2.lastwaittype), + v2.wait_resource, + COALESCE(NULLIF(sp2.blocked, sp2.spid), 0) + ) AS sp1 + ) AS sp0 + WHERE + @blocker = 1 + OR + (1=1 + ' + + --inclusive filter + CASE + WHEN @filter <> '' THEN + CASE @filter_type + WHEN 'session' THEN + CASE + WHEN CONVERT(SMALLINT, @filter) <> 0 THEN + 'AND sp0.session_id = CONVERT(SMALLINT, @filter) + ' + ELSE + '' + END + WHEN 'program' THEN + 'AND sp0.program_name LIKE @filter + ' + WHEN 'login' THEN + 'AND sp0.login_name LIKE @filter + ' + WHEN 'host' THEN + 'AND sp0.host_name LIKE @filter + ' + WHEN 'database' THEN + 'AND DB_NAME(sp0.database_id) LIKE @filter + ' + ELSE + '' + END + ELSE + '' + END + + --exclusive filter + CASE + WHEN @not_filter <> '' THEN + CASE @not_filter_type + WHEN 'session' THEN + CASE + WHEN CONVERT(SMALLINT, @not_filter) <> 0 THEN + 'AND sp0.session_id <> CONVERT(SMALLINT, @not_filter) + ' + ELSE + '' + END + WHEN 'program' THEN + 'AND sp0.program_name NOT LIKE @not_filter + ' + WHEN 'login' THEN + 'AND sp0.login_name NOT LIKE @not_filter + ' + WHEN 'host' THEN + 'AND sp0.host_name NOT LIKE @not_filter + ' + WHEN 'database' THEN + 'AND DB_NAME(sp0.database_id) NOT LIKE @not_filter + ' + ELSE + '' + END + ELSE + '' + END + + CASE @show_own_spid + WHEN 1 THEN + '' + ELSE + 'AND sp0.session_id <> @@spid + ' + END + + CASE + WHEN @show_system_spids = 0 THEN + 'AND sp0.hostprocess > '''' + ' + ELSE + '' + END + + CASE @show_sleeping_spids + WHEN 0 THEN + 'AND sp0.status <> ''sleeping'' + ' + WHEN 1 THEN + 'AND + ( + sp0.status <> ''sleeping'' + OR sp0.open_tran_count > 0 + ) + ' + ELSE + '' + END + + ') + ) AS spx + ) AS spy + WHERE + spy.r = 1; + ' + + CASE @recursion + WHEN 1 THEN + 'IF @@ROWCOUNT > 0 + BEGIN; + INSERT @blockers + ( + session_id + ) + SELECT TOP(@i) + blocked + FROM @sessions + WHERE + NULLIF(blocked, 0) IS NOT NULL + + EXCEPT + + SELECT TOP(@i) + session_id + FROM @sessions; + ' + + + CASE + WHEN + ( + @get_task_info > 0 + OR @find_block_leaders = 1 + ) THEN + 'IF @@ROWCOUNT > 0 + BEGIN; + SET @blocker = 1; + GOTO BLOCKERS; + END; + ' + ELSE + '' + END + + 'END; + ' + ELSE + '' + END + + 'SELECT TOP(@i) + @recursion AS recursion, + x.session_id, + x.request_id, + DENSE_RANK() OVER + ( + ORDER BY + x.session_id + ) AS session_number, + ' + + CASE + WHEN @output_column_list LIKE '%|[dd hh:mm:ss.mss|]%' ESCAPE '|' THEN + 'x.elapsed_time ' + ELSE + '0 ' + END + + 'AS elapsed_time, + ' + + CASE + WHEN + ( + @output_column_list LIKE '%|[dd hh:mm:ss.mss (avg)|]%' ESCAPE '|' OR + @output_column_list LIKE '%|[avg_elapsed_time|]%' ESCAPE '|' + ) + AND @recursion = 1 + THEN + 'x.avg_elapsed_time / 1000 ' + ELSE + 'NULL ' + END + + 'AS avg_elapsed_time, + ' + + CASE + WHEN + @output_column_list LIKE '%|[physical_io|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[physical_io_delta|]%' ESCAPE '|' + THEN + 'x.physical_io ' + ELSE + 'NULL ' + END + + 'AS physical_io, + ' + + CASE + WHEN + @output_column_list LIKE '%|[reads|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[reads_delta|]%' ESCAPE '|' + THEN + 'x.reads ' + ELSE + '0 ' + END + + 'AS reads, + ' + + CASE + WHEN + @output_column_list LIKE '%|[physical_reads|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[physical_reads_delta|]%' ESCAPE '|' + THEN + 'x.physical_reads ' + ELSE + '0 ' + END + + 'AS physical_reads, + ' + + CASE + WHEN + @output_column_list LIKE '%|[writes|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[writes_delta|]%' ESCAPE '|' + THEN + 'x.writes ' + ELSE + '0 ' + END + + 'AS writes, + ' + + CASE + WHEN + @output_column_list LIKE '%|[tempdb_allocations|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[tempdb_allocations_delta|]%' ESCAPE '|' + THEN + 'x.tempdb_allocations ' + ELSE + '0 ' + END + + 'AS tempdb_allocations, + ' + + CASE + WHEN + @output_column_list LIKE '%|[tempdb_current|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[tempdb_current_delta|]%' ESCAPE '|' + THEN + 'x.tempdb_current ' + ELSE + '0 ' + END + + 'AS tempdb_current, + ' + + CASE + WHEN + @output_column_list LIKE '%|[CPU|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[CPU_delta|]%' ESCAPE '|' + THEN + 'x.CPU ' + ELSE + '0 ' + END + + 'AS CPU, + ' + + CASE + WHEN + @output_column_list LIKE '%|[CPU_delta|]%' ESCAPE '|' + AND @get_task_info = 2 + AND @sys_info = 1 + THEN + 'x.thread_CPU_snapshot ' + ELSE + '0 ' + END + + 'AS thread_CPU_snapshot, + ' + + CASE + WHEN + @output_column_list LIKE '%|[context_switches|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[context_switches_delta|]%' ESCAPE '|' + THEN + 'x.context_switches ' + ELSE + 'NULL ' + END + + 'AS context_switches, + ' + + CASE + WHEN + @output_column_list LIKE '%|[used_memory|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[used_memory_delta|]%' ESCAPE '|' + THEN + CASE + WHEN @get_memory_info = 1 THEN + 'COALESCE(x.mg_used_memory_kb / 8, x.used_memory) ' + ELSE + 'x.used_memory ' + END + ELSE + '0 ' + END + + 'AS used_memory, + ' + + CASE + WHEN + @output_column_list LIKE '%|[max_used_memory|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[max_used_memory_delta|]%' ESCAPE '|' + THEN + 'x.max_used_memory_kb / 8 ' + ELSE + '0 ' + END + + 'AS max_used_memory, + ' + + CASE + WHEN + @output_column_list LIKE '%|[requested_memory|]%' ESCAPE '|' + THEN + 'x.requested_memory_kb / 8 ' + ELSE + '0 ' + END + + 'AS requested_memory, + ' + + CASE + WHEN + @output_column_list LIKE '%|[granted_memory|]%' ESCAPE '|' + THEN + 'x.mg_granted_memory_kb / 8 ' + ELSE + '0 ' + END + + 'AS granted_memory, + ' + + CASE + WHEN + @output_column_list LIKE '%|[tasks|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.tasks ' + ELSE + 'NULL ' + END + + 'AS tasks, + ' + + CASE + WHEN + ( + @output_column_list LIKE '%|[status|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[sql_command|]%' ESCAPE '|' + ) + AND @recursion = 1 + THEN + 'x.status ' + ELSE + ''''' ' + END + + 'AS status, + ' + + CASE + WHEN + @output_column_list LIKE '%|[wait_info|]%' ESCAPE '|' + AND @recursion = 1 + THEN + CASE @get_task_info + WHEN 2 THEN + 'COALESCE(x.task_wait_info, x.sys_wait_info) ' + ELSE + 'x.sys_wait_info ' + END + ELSE + 'NULL ' + END + + 'AS wait_info, + ' + + CASE + WHEN + ( + @output_column_list LIKE '%|[tran_start_time|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[tran_log_writes|]%' ESCAPE '|' + ) + AND @recursion = 1 + THEN + 'x.transaction_id ' + ELSE + 'NULL ' + END + + 'AS transaction_id, + ' + + CASE + WHEN + @output_column_list LIKE '%|[open_tran_count|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.open_tran_count ' + ELSE + 'NULL ' + END + + 'AS open_tran_count, + ' + + CASE + WHEN + @output_column_list LIKE '%|[sql_text|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.sql_handle ' + ELSE + 'NULL ' + END + + 'AS sql_handle, + ' + + CASE + WHEN + ( + @output_column_list LIKE '%|[sql_text|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[query_plan|]%' ESCAPE '|' + ) + AND @recursion = 1 + THEN + 'x.statement_start_offset ' + ELSE + 'NULL ' + END + + 'AS statement_start_offset, + ' + + CASE + WHEN + ( + @output_column_list LIKE '%|[sql_text|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[query_plan|]%' ESCAPE '|' + ) + AND @recursion = 1 + THEN + 'x.statement_end_offset ' + ELSE + 'NULL ' + END + + 'AS statement_end_offset, + ' + + 'NULL AS sql_text, + ' + + CASE + WHEN + @output_column_list LIKE '%|[query_plan|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.plan_handle ' + ELSE + 'NULL ' + END + + 'AS plan_handle, + ' + + CASE + WHEN + @output_column_list LIKE '%|[blocking_session_id|]%' ESCAPE '|' OR @find_block_leaders = 1 + AND @recursion = 1 + THEN + 'NULLIF(x.blocking_session_id, 0) ' + ELSE + 'NULL ' + END + + 'AS blocking_session_id, + ' + + CASE + WHEN + @output_column_list LIKE '%|[percent_complete|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.percent_complete ' + ELSE + 'NULL ' + END + + 'AS percent_complete, + ' + + CASE + WHEN + @output_column_list LIKE '%|[host_name|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.host_name ' + ELSE + ''''' ' + END + + 'AS host_name, + ' + + CASE + WHEN + @output_column_list LIKE '%|[login_name|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.login_name ' + ELSE + ''''' ' + END + + 'AS login_name, + ' + + CASE + WHEN + @output_column_list LIKE '%|[database_name|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'DB_NAME(x.database_id) ' + ELSE + 'NULL ' + END + + 'AS database_name, + ' + + CASE + WHEN + @output_column_list LIKE '%|[program_name|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.program_name ' + ELSE + ''''' ' + END + + 'AS program_name, + ' + + CASE + WHEN + @output_column_list LIKE '%|[additional_info|]%' ESCAPE '|' + AND @recursion = 1 + THEN + '( + SELECT TOP(@i) + x.text_size, + x.language, + x.date_format, + x.date_first, + CASE x.quoted_identifier + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS quoted_identifier, + CASE x.arithabort + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS arithabort, + CASE x.ansi_null_dflt_on + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS ansi_null_dflt_on, + CASE x.ansi_defaults + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS ansi_defaults, + CASE x.ansi_warnings + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS ansi_warnings, + CASE x.ansi_padding + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS ansi_padding, + CASE ansi_nulls + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS ansi_nulls, + CASE x.concat_null_yields_null + WHEN 0 THEN ''OFF'' + WHEN 1 THEN ''ON'' + END AS concat_null_yields_null, + CASE x.transaction_isolation_level + WHEN 0 THEN ''Unspecified'' + WHEN 1 THEN ''ReadUncomitted'' + WHEN 2 THEN ''ReadCommitted'' + WHEN 3 THEN ''Repeatable'' + WHEN 4 THEN ''Serializable'' + WHEN 5 THEN ''Snapshot'' + END AS transaction_isolation_level, + x.lock_timeout, + x.deadlock_priority, + x.row_count, + x.command_type, + ' + + CASE + WHEN OBJECT_ID('master.dbo.fn_varbintohexstr') IS NOT NULL THEN + 'master.dbo.fn_varbintohexstr(x.sql_handle) AS sql_handle, + master.dbo.fn_varbintohexstr(x.plan_handle) AS plan_handle,' + ELSE + 'CONVERT(VARCHAR(256), x.sql_handle, 1) AS sql_handle, + CONVERT(VARCHAR(256), x.plan_handle, 1) AS plan_handle,' + END + + ' + x.statement_start_offset, + x.statement_end_offset, + ' + + CASE + WHEN @output_column_list LIKE '%|[program_name|]%' ESCAPE '|' THEN + '( + SELECT TOP(1) + CONVERT(uniqueidentifier, CONVERT(XML, '''').value(''xs:hexBinary( substring(sql:column("agent_info.job_id_string"), 0) )'', ''binary(16)'')) AS job_id, + agent_info.step_id, + ( + SELECT TOP(1) + NULL + FOR XML + PATH(''job_name''), + TYPE + ), + ( + SELECT TOP(1) + NULL + FOR XML + PATH(''step_name''), + TYPE + ) + FROM + ( + SELECT TOP(1) + SUBSTRING(x.program_name, CHARINDEX(''0x'', x.program_name) + 2, 32) AS job_id_string, + SUBSTRING(x.program_name, CHARINDEX('': Step '', x.program_name) + 7, CHARINDEX('')'', x.program_name, CHARINDEX('': Step '', x.program_name)) - (CHARINDEX('': Step '', x.program_name) + 7)) AS step_id + WHERE + x.program_name LIKE N''SQLAgent - TSQL JobStep (Job 0x%'' + ) AS agent_info + FOR XML + PATH(''agent_job_info''), + TYPE + ), + ' + ELSE '' + END + + CASE + WHEN @get_task_info = 2 THEN + 'CONVERT(XML, x.block_info) AS block_info, + ' + ELSE + '' + END + ' + x.host_process_id, + x.group_id, + x.original_login_name, + ' + + CASE + WHEN OBJECT_ID('master.dbo.fn_varbintohexstr') IS NOT NULL THEN + 'master.dbo.fn_varbintohexstr(x.context_info) AS context_info' + ELSE + 'CONVERT(VARCHAR(256), x.context_info, 1) AS context_info' + END + ' + FOR XML + PATH(''additional_info''), + TYPE + ) ' + ELSE + 'NULL ' + END + + 'AS additional_info, + ' + + CASE + WHEN + @output_column_list LIKE '%|[memory_info|]%' ESCAPE '|' + AND @get_memory_info = 1 THEN' + ( + SELECT TOP(@i) + ( + SELECT TOP(@i) + x.request_time, + x.grant_time, + x.wait_time_ms, + x.requested_memory_kb, + x.mg_granted_memory_kb AS granted_memory_kb, + x.mg_used_memory_kb AS used_memory_kb, + x.max_used_memory_kb, + x.ideal_memory_kb, + x.required_memory_kb, + x.queue_id, + x.wait_order, + x.is_next_candidate, + x.dop, + CAST(x.query_cost AS NUMERIC(38, 4)) AS query_cost + FOR XML + PATH(''memory_grant''), + TYPE + ), + ( + SELECT TOP(@i) + x.timeout_error_count, + x.target_memory_kb, + x.max_target_memory_kb, + x.total_memory_kb, + x.available_memory_kb, + x.rs_granted_memory_kb AS granted_memory_kb, + x.rs_used_memory_kb AS used_memory_kb, + x.grantee_count, + x.waiter_count + FOR XML + PATH(''resource_semaphore''), + TYPE + ), + ( + SELECT TOP(@i) + x.wg_name AS name, + x.request_max_memory_grant_percent, + x.request_max_cpu_time_sec, + x.request_memory_grant_timeout_sec, + x.max_dop + FOR XML + PATH(''workload_group''), + TYPE + ), + ( + SELECT TOP(@i) + x.rp_name AS name, + x.min_memory_percent, + x.max_memory_percent, + x.min_cpu_percent, + x.max_cpu_percent + FOR XML + PATH(''resource_pool''), + TYPE + ) + WHERE + x.request_time IS NOT NULL + FOR XML + PATH(''memory_info''), + TYPE + ) + ' + ELSE + 'NULL ' + END + 'AS memory_info, + x.start_time, + ' + + + CASE + WHEN + @output_column_list LIKE '%|[login_time|]%' ESCAPE '|' + AND @recursion = 1 + THEN + 'x.login_time ' + ELSE + 'NULL ' + END + + 'AS login_time, + x.last_request_start_time + FROM + ( + SELECT TOP(@i) + y.*, + CASE + WHEN DATEDIFF(hour, y.start_time, GETDATE()) > 576 THEN + DATEDIFF(second, GETDATE(), y.start_time) + ELSE DATEDIFF(ms, y.start_time, GETDATE()) + END AS elapsed_time, + COALESCE(tempdb_info.tempdb_allocations, 0) AS tempdb_allocations, + COALESCE + ( + CASE + WHEN tempdb_info.tempdb_current < 0 THEN 0 + ELSE tempdb_info.tempdb_current + END, + 0 + ) AS tempdb_current, + ' + + CASE + WHEN + ( + @get_task_info <> 0 + OR @find_block_leaders = 1 + ) THEN + 'N''('' + CONVERT(NVARCHAR, y.wait_duration_ms) + N''ms)'' + + y.wait_type + + CASE + WHEN y.wait_type LIKE N''PAGE%LATCH_%'' THEN + N'':'' + + COALESCE(DB_NAME(CONVERT(INT, LEFT(y.resource_description, CHARINDEX(N'':'', y.resource_description) - 1))), N''(null)'') + + N'':'' + + SUBSTRING(y.resource_description, CHARINDEX(N'':'', y.resource_description) + 1, LEN(y.resource_description) - CHARINDEX(N'':'', REVERSE(y.resource_description)) - CHARINDEX(N'':'', y.resource_description)) + + N''('' + + CASE + WHEN + CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) = 1 OR + CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) % 8088 = 0 + THEN + N''PFS'' + WHEN + CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) = 2 OR + CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) % 511232 = 0 + THEN + N''GAM'' + WHEN + CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) = 3 OR + (CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) - 1) % 511232 = 0 + THEN + N''SGAM'' + WHEN + CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) = 6 OR + (CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) - 6) % 511232 = 0 + THEN + N''DCM'' + WHEN + CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) = 7 OR + (CONVERT(INT, RIGHT(y.resource_description, CHARINDEX(N'':'', REVERSE(y.resource_description)) - 1)) - 7) % 511232 = 0 + THEN + N''BCM'' + ELSE + N''*'' + END + + N'')'' + WHEN y.wait_type IN (N''CXPACKET'', N''CXCONSUMER'', N''CXSYNC_PORT'', N''CXSYNC_CONSUMER'') THEN + N'':'' + + SUBSTRING + ( + y.resource_description, + CHARINDEX(N''nodeId'', y.resource_description) + 7, + CASE + WHEN CHARINDEX(N'' '', y.resource_description, CHARINDEX(N''nodeId'', y.resource_description)) > 0 + THEN CHARINDEX(N'' '', y.resource_description, CHARINDEX(N''nodeId'', y.resource_description) + 7) - 7 - CHARINDEX(N''nodeId'', y.resource_description) + ELSE 4 + END + ) + WHEN y.wait_type LIKE N''LATCH[_]%'' THEN + N'' ['' + LEFT(y.resource_description, COALESCE(NULLIF(CHARINDEX(N'' '', y.resource_description), 0), LEN(y.resource_description) + 1) - 1) + N'']'' + WHEN + y.wait_type = N''OLEDB'' + AND y.resource_description LIKE N''%(SPID=%)'' THEN + N''['' + LEFT(y.resource_description, CHARINDEX(N''(SPID='', y.resource_description) - 2) + + N'':'' + SUBSTRING(y.resource_description, CHARINDEX(N''(SPID='', y.resource_description) + 6, CHARINDEX(N'')'', y.resource_description, (CHARINDEX(N''(SPID='', y.resource_description) + 6)) - (CHARINDEX(N''(SPID='', y.resource_description) + 6)) + '']'' + ELSE + N'''' + END COLLATE Latin1_General_Bin2 AS sys_wait_info, + ' + ELSE + '' + END + + CASE + WHEN @get_task_info = 2 THEN + 'tasks.physical_io, + tasks.context_switches, + tasks.tasks, + tasks.block_info, + tasks.wait_info AS task_wait_info, + tasks.thread_CPU_snapshot, + ' + ELSE + '' + END + + CASE + WHEN NOT (@get_avg_time = 1 AND @recursion = 1) THEN + 'CONVERT(INT, NULL) ' + ELSE + 'qs.total_elapsed_time / qs.execution_count ' + END + + 'AS avg_elapsed_time + FROM + ( + SELECT TOP(@i) + sp.session_id, + sp.request_id, + COALESCE(r.logical_reads, s.logical_reads) AS reads, + COALESCE(r.reads, s.reads) AS physical_reads, + COALESCE(r.writes, s.writes) AS writes, + COALESCE(r.CPU_time, s.CPU_time) AS CPU, + ' + + CASE + WHEN @get_memory_info = 1 THEN + 'sp.memory_usage AS used_memory, + mg.used_memory_kb AS mg_used_memory_kb, + mg.max_used_memory_kb, + mg.request_time, + mg.grant_time, + mg.wait_time_ms, + mg.requested_memory_kb, + mg.granted_memory_kb AS mg_granted_memory_kb, + mg.required_memory_kb, + mg.ideal_memory_kb, + mg.dop AS dop, + mg.query_cost AS query_cost, + mg.queue_id AS queue_id, + mg.wait_order AS wait_order, + mg.is_next_candidate, + rs.target_memory_kb, + rs.max_target_memory_kb, + rs.total_memory_kb, + rs.available_memory_kb, + rs.granted_memory_kb AS rs_granted_memory_kb, + rs.used_memory_kb AS rs_used_memory_kb, + rs.grantee_count, + rs.waiter_count, + rs.timeout_error_count, + wg.name AS wg_name, + wg.request_max_memory_grant_percent, + wg.request_max_cpu_time_sec, + wg.request_memory_grant_timeout_sec, + wg.max_dop, + rp.name AS rp_name, + rp.min_memory_percent, + rp.max_memory_percent, + rp.min_cpu_percent, + rp.max_cpu_percent, + ' + ELSE + 'sp.memory_usage + COALESCE(r.granted_query_memory, 0) AS used_memory, + ' + END + + 'LOWER(sp.status) AS status, + COALESCE(r.sql_handle, sp.sql_handle) AS sql_handle, + COALESCE(r.statement_start_offset, sp.statement_start_offset) AS statement_start_offset, + COALESCE(r.statement_end_offset, sp.statement_end_offset) AS statement_end_offset, + ' + + CASE + WHEN + ( + @get_task_info <> 0 + OR @find_block_leaders = 1 + ) THEN + 'sp.wait_type COLLATE Latin1_General_Bin2 AS wait_type, + sp.wait_resource COLLATE Latin1_General_Bin2 AS resource_description, + sp.wait_time AS wait_duration_ms, + ' + ELSE + '' + END + + 'NULLIF(sp.blocked, 0) AS blocking_session_id, + r.plan_handle, + NULLIF(r.percent_complete, 0) AS percent_complete, + sp.host_name, + sp.login_name, + sp.program_name, + s.host_process_id, + COALESCE(r.text_size, s.text_size) AS text_size, + COALESCE(r.language, s.language) AS language, + COALESCE(r.date_format, s.date_format) AS date_format, + COALESCE(r.date_first, s.date_first) AS date_first, + COALESCE(r.quoted_identifier, s.quoted_identifier) AS quoted_identifier, + COALESCE(r.arithabort, s.arithabort) AS arithabort, + COALESCE(r.ansi_null_dflt_on, s.ansi_null_dflt_on) AS ansi_null_dflt_on, + COALESCE(r.ansi_defaults, s.ansi_defaults) AS ansi_defaults, + COALESCE(r.ansi_warnings, s.ansi_warnings) AS ansi_warnings, + COALESCE(r.ansi_padding, s.ansi_padding) AS ansi_padding, + COALESCE(r.ansi_nulls, s.ansi_nulls) AS ansi_nulls, + COALESCE(r.concat_null_yields_null, s.concat_null_yields_null) AS concat_null_yields_null, + COALESCE(r.transaction_isolation_level, s.transaction_isolation_level) AS transaction_isolation_level, + COALESCE(r.lock_timeout, s.lock_timeout) AS lock_timeout, + COALESCE(r.deadlock_priority, s.deadlock_priority) AS deadlock_priority, + COALESCE(r.row_count, s.row_count) AS row_count, + COALESCE(r.command, sp.cmd) AS command_type, + NULLIF(COALESCE(r.context_info, s.context_info), 0x) AS context_info, + COALESCE + ( + CASE + WHEN + ( + s.is_user_process = 0 + AND r.total_elapsed_time >= 0 + ) THEN + DATEADD + ( + ms, + 1000 * (DATEPART(ms, DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE())) / 500) - DATEPART(ms, DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE())), + DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE()) + ) + END, + NULLIF(COALESCE(r.start_time, sp.last_request_end_time), CONVERT(DATETIME, ''19000101'', 112)), + sp.login_time + ) AS start_time, + sp.login_time, + CASE + WHEN s.is_user_process = 1 THEN + s.last_request_start_time + ELSE + COALESCE + ( + DATEADD + ( + ms, + 1000 * (DATEPART(ms, DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE())) / 500) - DATEPART(ms, DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE())), + DATEADD(second, -(r.total_elapsed_time / 1000), GETDATE()) + ), + s.last_request_start_time + ) + END AS last_request_start_time, + r.transaction_id, + sp.database_id, + sp.open_tran_count, + ' + + CASE + WHEN EXISTS + ( + SELECT + * + FROM sys.all_columns AS ac + WHERE + ac.object_id = OBJECT_ID('sys.dm_exec_sessions') + AND ac.name = 'group_id' + ) + THEN 's.group_id,' + ELSE 'CONVERT(INT, NULL) AS group_id,' + END + ' + s.original_login_name + FROM ' + + CASE + WHEN @get_memory_info = 1 THEN + '( + SELECT TOP(@i) + rp0.* + FROM sys.resource_governor_resource_pools AS rp0 + ) AS rp + RIGHT OUTER HASH JOIN + ( + ( + SELECT TOP(@i) + wg0.* + FROM sys.resource_governor_workload_groups AS wg0 + ) AS wg + RIGHT OUTER HASH JOIN + ( + ( + SELECT TOP(@i) + rs0.* + FROM sys.dm_exec_query_resource_semaphores AS rs0 + ) AS rs + RIGHT OUTER HASH JOIN + ( + ' + @core_session_join + + 'LEFT OUTER LOOP JOIN sys.dm_exec_query_memory_grants AS mg ON + sp.session_id = mg.session_id + AND sp.request_id = mg.request_id + ) ON + rs.resource_semaphore_id = mg.resource_semaphore_id + AND rs.pool_id = mg.pool_id + ) ON + wg.group_id = s.group_id + ) ON + rp.pool_id = wg.pool_id ' + ELSE @core_session_join + END + ' + ) AS y + ' + + CASE + WHEN @get_task_info = 2 THEN + CONVERT(VARCHAR(MAX), '') + + 'LEFT OUTER HASH JOIN + ( + SELECT TOP(@i) + task_nodes.task_node.value(''(session_id/text())[1]'', ''SMALLINT'') AS session_id, + task_nodes.task_node.value(''(request_id/text())[1]'', ''INT'') AS request_id, + task_nodes.task_node.value(''(physical_io/text())[1]'', ''BIGINT'') AS physical_io, + task_nodes.task_node.value(''(context_switches/text())[1]'', ''BIGINT'') AS context_switches, + task_nodes.task_node.value(''(tasks/text())[1]'', ''INT'') AS tasks, + task_nodes.task_node.value(''(block_info/text())[1]'', ''NVARCHAR(4000)'') AS block_info, + task_nodes.task_node.value(''(waits/text())[1]'', ''NVARCHAR(4000)'') AS wait_info, + task_nodes.task_node.value(''(thread_CPU_snapshot/text())[1]'', ''BIGINT'') AS thread_CPU_snapshot + FROM + ( + SELECT TOP(@i) + CONVERT + ( + XML, + REPLACE + ( + CONVERT(NVARCHAR(MAX), tasks_raw.task_xml_raw) COLLATE Latin1_General_Bin2, + N'''', + N'', '' + ) + ) AS task_xml + FROM + ( + SELECT TOP(@i) + CASE waits.r + WHEN 1 THEN + waits.session_id + ELSE + NULL + END AS [session_id], + CASE waits.r + WHEN 1 THEN + waits.request_id + ELSE + NULL + END AS [request_id], + CASE waits.r + WHEN 1 THEN + waits.physical_io + ELSE + NULL + END AS [physical_io], + CASE waits.r + WHEN 1 THEN + waits.context_switches + ELSE + NULL + END AS [context_switches], + CASE waits.r + WHEN 1 THEN + waits.thread_CPU_snapshot + ELSE + NULL + END AS [thread_CPU_snapshot], + CASE waits.r + WHEN 1 THEN + waits.tasks + ELSE + NULL + END AS [tasks], + CASE waits.r + WHEN 1 THEN + waits.block_info + ELSE + NULL + END AS [block_info], + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + CONVERT + ( + NVARCHAR(MAX), + N''('' + + CONVERT(NVARCHAR, num_waits) + N''x: '' + + CASE num_waits + WHEN 1 THEN + CONVERT(NVARCHAR, min_wait_time) + N''ms'' + WHEN 2 THEN + CASE + WHEN min_wait_time <> max_wait_time THEN + CONVERT(NVARCHAR, min_wait_time) + N''/'' + CONVERT(NVARCHAR, max_wait_time) + N''ms'' + ELSE + CONVERT(NVARCHAR, max_wait_time) + N''ms'' + END + ELSE + CASE + WHEN min_wait_time <> max_wait_time THEN + CONVERT(NVARCHAR, min_wait_time) + N''/'' + CONVERT(NVARCHAR, avg_wait_time) + N''/'' + CONVERT(NVARCHAR, max_wait_time) + N''ms'' + ELSE + CONVERT(NVARCHAR, max_wait_time) + N''ms'' + END + END + + N'')'' + wait_type COLLATE Latin1_General_Bin2 + ), + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ) AS [waits] + FROM + ( + SELECT TOP(@i) + w1.*, + ROW_NUMBER() OVER + ( + PARTITION BY + w1.session_id, + w1.request_id + ORDER BY + w1.block_info DESC, + w1.num_waits DESC, + w1.wait_type + ) AS r + FROM + ( + SELECT TOP(@i) + task_info.session_id, + task_info.request_id, + task_info.physical_io, + task_info.context_switches, + task_info.thread_CPU_snapshot, + task_info.num_tasks AS tasks, + CASE + WHEN task_info.runnable_time IS NOT NULL THEN + ''RUNNABLE'' + ELSE + wt2.wait_type + END AS wait_type, + NULLIF(COUNT(COALESCE(task_info.runnable_time, wt2.waiting_task_address)), 0) AS num_waits, + MIN(COALESCE(task_info.runnable_time, wt2.wait_duration_ms)) AS min_wait_time, + AVG(COALESCE(task_info.runnable_time, wt2.wait_duration_ms)) AS avg_wait_time, + MAX(COALESCE(task_info.runnable_time, wt2.wait_duration_ms)) AS max_wait_time, + MAX(wt2.block_info) AS block_info + FROM + ( + SELECT TOP(@i) + t.session_id, + t.request_id, + SUM(CONVERT(BIGINT, t.pending_io_count)) OVER (PARTITION BY t.session_id, t.request_id) AS physical_io, + SUM(CONVERT(BIGINT, t.context_switches_count)) OVER (PARTITION BY t.session_id, t.request_id) AS context_switches, + ' + + CASE + WHEN + @output_column_list LIKE '%|[CPU_delta|]%' ESCAPE '|' + AND @sys_info = 1 + THEN + 'SUM(tr.usermode_time + tr.kernel_time) OVER (PARTITION BY t.session_id, t.request_id) ' + ELSE + 'CONVERT(BIGINT, NULL) ' + END + + ' AS thread_CPU_snapshot, + COUNT(*) OVER (PARTITION BY t.session_id, t.request_id) AS num_tasks, + t.task_address, + t.task_state, + CASE + WHEN + t.task_state = ''RUNNABLE'' + AND w.runnable_time > 0 THEN + w.runnable_time + ELSE + NULL + END AS runnable_time + FROM sys.dm_os_tasks AS t + CROSS APPLY + ( + SELECT TOP(1) + sp2.session_id + FROM @sessions AS sp2 + WHERE + sp2.session_id = t.session_id + AND sp2.request_id = t.request_id + AND sp2.status <> ''sleeping'' + ) AS sp20 + LEFT OUTER HASH JOIN + ( + ' + + CASE + WHEN @sys_info = 1 THEN + 'SELECT TOP(@i) + ( + SELECT TOP(@i) + ms_ticks + FROM sys.dm_os_sys_info + ) - + w0.wait_resumed_ms_ticks AS runnable_time, + w0.worker_address, + w0.thread_address, + w0.task_bound_ms_ticks + FROM sys.dm_os_workers AS w0 + WHERE + w0.state = ''RUNNABLE'' + OR @first_collection_ms_ticks >= w0.task_bound_ms_ticks' + ELSE + 'SELECT + CONVERT(BIGINT, NULL) AS runnable_time, + CONVERT(VARBINARY(8), NULL) AS worker_address, + CONVERT(VARBINARY(8), NULL) AS thread_address, + CONVERT(BIGINT, NULL) AS task_bound_ms_ticks + WHERE + 1 = 0' + END + + ' + ) AS w ON + w.worker_address = t.worker_address + ' + + CASE + WHEN + @output_column_list LIKE '%|[CPU_delta|]%' ESCAPE '|' + AND @sys_info = 1 + THEN + 'LEFT OUTER HASH JOIN sys.dm_os_threads AS tr ON + tr.thread_address = w.thread_address + AND @first_collection_ms_ticks >= w.task_bound_ms_ticks + ' + ELSE + '' + END + + ') AS task_info + LEFT OUTER HASH JOIN + ( + SELECT TOP(@i) + wt1.wait_type, + wt1.waiting_task_address, + MAX(wt1.wait_duration_ms) AS wait_duration_ms, + MAX(wt1.block_info) AS block_info + FROM + ( + SELECT DISTINCT TOP(@i) + wt.wait_type + + CASE + WHEN wt.wait_type LIKE N''PAGE%LATCH_%'' THEN + '':'' + + COALESCE(DB_NAME(CONVERT(INT, LEFT(wt.resource_description, CHARINDEX(N'':'', wt.resource_description) - 1))), N''(null)'') + + N'':'' + + SUBSTRING(wt.resource_description, CHARINDEX(N'':'', wt.resource_description) + 1, LEN(wt.resource_description) - CHARINDEX(N'':'', REVERSE(wt.resource_description)) - CHARINDEX(N'':'', wt.resource_description)) + + N''('' + + CASE + WHEN + CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) = 1 OR + CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) % 8088 = 0 + THEN + N''PFS'' + WHEN + CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) = 2 OR + CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) % 511232 = 0 + THEN + N''GAM'' + WHEN + CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) = 3 OR + (CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) - 1) % 511232 = 0 + THEN + N''SGAM'' + WHEN + CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) = 6 OR + (CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) - 6) % 511232 = 0 + THEN + N''DCM'' + WHEN + CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) = 7 OR + (CONVERT(INT, RIGHT(wt.resource_description, CHARINDEX(N'':'', REVERSE(wt.resource_description)) - 1)) - 7) % 511232 = 0 + THEN + N''BCM'' + ELSE + N''*'' + END + + N'')'' + WHEN wt.wait_type IN (N''CXPACKET'', N''CXCONSUMER'', N''CXSYNC_PORT'', N''CXSYNC_CONSUMER'') THEN + N'':'' + + SUBSTRING + ( + wt.resource_description, + CHARINDEX(N''nodeId'', wt.resource_description) + 7, + CASE + WHEN CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''nodeId'', wt.resource_description)) > 0 + THEN CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''nodeId'', wt.resource_description) + 7) - 7 - CHARINDEX(N''nodeId'', wt.resource_description) + ELSE 4 + END + ) + WHEN wt.wait_type LIKE N''LATCH[_]%'' THEN + N'' ['' + LEFT(wt.resource_description, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description), 0), LEN(wt.resource_description) + 1) - 1) + N'']'' + ELSE + N'''' + END COLLATE Latin1_General_Bin2 AS wait_type, + CASE + WHEN + ( + wt.blocking_session_id IS NOT NULL + AND wt.wait_type LIKE N''LCK[_]%'' + ) THEN + ( + SELECT TOP(@i) + x.lock_type, + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + DB_NAME + ( + CONVERT + ( + INT, + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''dbid='', wt.resource_description), 0) + 5, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''dbid='', wt.resource_description) + 5), 0), LEN(wt.resource_description) + 1) - CHARINDEX(N''dbid='', wt.resource_description) - 5) + ) + ), + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ) AS database_name, + CASE x.lock_type + WHEN N''objectlock'' THEN + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''objid='', wt.resource_description), 0) + 6, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''objid='', wt.resource_description) + 6), 0), LEN(wt.resource_description) + 1) - CHARINDEX(N''objid='', wt.resource_description) - 6) + ELSE + NULL + END AS object_id, + CASE x.lock_type + WHEN N''filelock'' THEN + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''fileid='', wt.resource_description), 0) + 7, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''fileid='', wt.resource_description) + 7), 0), LEN(wt.resource_description) + 1) - CHARINDEX(N''fileid='', wt.resource_description) - 7) + ELSE + NULL + END AS file_id, + CASE + WHEN x.lock_type in (N''pagelock'', N''extentlock'', N''ridlock'') THEN + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''associatedObjectId='', wt.resource_description), 0) + 19, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''associatedObjectId='', wt.resource_description) + 19), 0), LEN(wt.resource_description) + 1) - CHARINDEX(N''associatedObjectId='', wt.resource_description) - 19) + WHEN x.lock_type in (N''keylock'', N''hobtlock'', N''allocunitlock'') THEN + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''hobtid='', wt.resource_description), 0) + 7, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''hobtid='', wt.resource_description) + 7), 0), LEN(wt.resource_description) + 1) - CHARINDEX(N''hobtid='', wt.resource_description) - 7) + ELSE + NULL + END AS hobt_id, + CASE x.lock_type + WHEN N''applicationlock'' THEN + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''hash='', wt.resource_description), 0) + 5, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''hash='', wt.resource_description) + 5), 0), LEN(wt.resource_description) + 1) - CHARINDEX(N''hash='', wt.resource_description) - 5) + ELSE + NULL + END AS applock_hash, + CASE x.lock_type + WHEN N''metadatalock'' THEN + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''subresource='', wt.resource_description), 0) + 12, COALESCE(NULLIF(CHARINDEX(N'' '', wt.resource_description, CHARINDEX(N''subresource='', wt.resource_description) + 12), 0), LEN(wt.resource_description) + 1) - CHARINDEX(N''subresource='', wt.resource_description) - 12) + ELSE + NULL + END AS metadata_resource, + CASE x.lock_type + WHEN N''metadatalock'' THEN + SUBSTRING(wt.resource_description, NULLIF(CHARINDEX(N''classid='', wt.resource_description), 0) + 8, COALESCE(NULLIF(CHARINDEX(N'' dbid='', wt.resource_description) - CHARINDEX(N''classid='', wt.resource_description), 0), LEN(wt.resource_description) + 1) - 8) + ELSE + NULL + END AS metadata_class_id + FROM + ( + SELECT TOP(1) + LEFT(wt.resource_description, CHARINDEX(N'' '', wt.resource_description) - 1) COLLATE Latin1_General_Bin2 AS lock_type + ) AS x + FOR XML + PATH('''') + ) + ELSE NULL + END AS block_info, + wt.wait_duration_ms, + wt.waiting_task_address + FROM + ( + SELECT TOP(@i) + wt0.wait_type COLLATE Latin1_General_Bin2 AS wait_type, + LEFT + ( + p.resource_description, + ISNULL(NULLIF(CHARINDEX('' (LATCH '', p.resource_description) - 1, -1), 256) + ) AS resource_description, + wt0.wait_duration_ms, + wt0.waiting_task_address, + CASE + WHEN wt0.blocking_session_id = p.blocked THEN + wt0.blocking_session_id + ELSE + NULL + END AS blocking_session_id + FROM sys.dm_os_waiting_tasks AS wt0 + CROSS APPLY + ( + SELECT TOP(1) + s0.blocked, + wt0.resource_description COLLATE Latin1_General_Bin2 AS resource_description + FROM @sessions AS s0 + WHERE + s0.session_id = wt0.session_id + AND COALESCE(s0.wait_type, N'''') <> N''OLEDB'' + AND wt0.wait_type <> N''OLEDB'' + ) AS p + ) AS wt + ) AS wt1 + GROUP BY + wt1.wait_type, + wt1.waiting_task_address + ) AS wt2 ON + wt2.waiting_task_address = task_info.task_address + AND wt2.wait_duration_ms > 0 + AND task_info.runnable_time IS NULL + GROUP BY + task_info.session_id, + task_info.request_id, + task_info.physical_io, + task_info.context_switches, + task_info.thread_CPU_snapshot, + task_info.num_tasks, + CASE + WHEN task_info.runnable_time IS NOT NULL THEN + ''RUNNABLE'' + ELSE + wt2.wait_type + END + ) AS w1 + ) AS waits + ORDER BY + waits.session_id, + waits.request_id, + waits.r + FOR XML + PATH(N''tasks''), + TYPE + ) AS tasks_raw (task_xml_raw) + ) AS tasks_final + CROSS APPLY tasks_final.task_xml.nodes(N''/tasks'') AS task_nodes (task_node) + WHERE + task_nodes.task_node.exist(N''session_id'') = 1 + ) AS tasks ON + tasks.session_id = y.session_id + AND tasks.request_id = y.request_id + ' + ELSE + '' + END + + 'LEFT OUTER HASH JOIN + ( + SELECT TOP(@i) + t_info.session_id, + COALESCE(t_info.request_id, -1) AS request_id, + SUM(t_info.tempdb_allocations) AS tempdb_allocations, + SUM(t_info.tempdb_current) AS tempdb_current + FROM + ( + SELECT TOP(@i) + tsu.session_id, + tsu.request_id, + tsu.user_objects_alloc_page_count + + tsu.internal_objects_alloc_page_count AS tempdb_allocations, + tsu.user_objects_alloc_page_count + + tsu.internal_objects_alloc_page_count - + tsu.user_objects_dealloc_page_count - + tsu.internal_objects_dealloc_page_count AS tempdb_current + FROM sys.dm_db_task_space_usage AS tsu + CROSS APPLY + ( + SELECT TOP(1) + s0.session_id + FROM @sessions AS s0 + WHERE + s0.session_id = tsu.session_id + ) AS p + + UNION ALL + + SELECT TOP(@i) + ssu.session_id, + NULL AS request_id, + ssu.user_objects_alloc_page_count + + ssu.internal_objects_alloc_page_count AS tempdb_allocations, + ssu.user_objects_alloc_page_count + + ssu.internal_objects_alloc_page_count - + ssu.user_objects_dealloc_page_count - + ssu.internal_objects_dealloc_page_count AS tempdb_current + FROM sys.dm_db_session_space_usage AS ssu + CROSS APPLY + ( + SELECT TOP(1) + s0.session_id + FROM @sessions AS s0 + WHERE + s0.session_id = ssu.session_id + ) AS p + ) AS t_info + GROUP BY + t_info.session_id, + COALESCE(t_info.request_id, -1) + ) AS tempdb_info ON + tempdb_info.session_id = y.session_id + AND tempdb_info.request_id = + CASE + WHEN y.status = N''sleeping'' THEN + -1 + ELSE + y.request_id + END + ' + + CASE + WHEN + NOT + ( + @get_avg_time = 1 + AND @recursion = 1 + ) THEN + '' + ELSE + 'LEFT OUTER HASH JOIN + ( + SELECT TOP(@i) + * + FROM sys.dm_exec_query_stats + ) AS qs ON + qs.sql_handle = y.sql_handle + AND qs.plan_handle = y.plan_handle + AND qs.statement_start_offset = y.statement_start_offset + AND qs.statement_end_offset = y.statement_end_offset + ' + END + + ') AS x + OPTION (KEEPFIXED PLAN, OPTIMIZE FOR (@i = 1)); '; + + SET @sql_n = CONVERT(NVARCHAR(MAX), @sql); + + SET @last_collection_start = GETDATE(); + + IF + @recursion = -1 + AND @sys_info = 1 + BEGIN; + SELECT + @first_collection_ms_ticks = ms_ticks + FROM sys.dm_os_sys_info; + END; + + INSERT #sessions + ( + recursion, + session_id, + request_id, + session_number, + elapsed_time, + avg_elapsed_time, + physical_io, + reads, + physical_reads, + writes, + tempdb_allocations, + tempdb_current, + CPU, + thread_CPU_snapshot, + context_switches, + used_memory, + max_used_memory, + requested_memory, + granted_memory, + tasks, + status, + wait_info, + transaction_id, + open_tran_count, + sql_handle, + statement_start_offset, + statement_end_offset, + sql_text, + plan_handle, + blocking_session_id, + percent_complete, + host_name, + login_name, + database_name, + program_name, + additional_info, + memory_info, + start_time, + login_time, + last_request_start_time + ) + EXEC sp_executesql + @sql_n, + N'@recursion SMALLINT, @filter sysname, @not_filter sysname, @first_collection_ms_ticks BIGINT', + @recursion, @filter, @not_filter, @first_collection_ms_ticks; + + --Collect transaction information? + IF + @recursion = 1 + AND + ( + @output_column_list LIKE '%|[tran_start_time|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[tran_log_writes|]%' ESCAPE '|' + OR @output_column_list LIKE '%|[implicit_tran|]%' ESCAPE '|' + ) + BEGIN; + DECLARE @i INT; + SET @i = 2147483647; + + UPDATE s + SET + tran_start_time = + CONVERT + ( + DATETIME, + LEFT + ( + x.trans_info, + NULLIF(CHARINDEX(NCHAR(254) COLLATE Latin1_General_Bin2, x.trans_info) - 1, -1) + ), + 121 + ), + tran_log_writes = + RIGHT + ( + x.trans_info, + LEN(x.trans_info) - CHARINDEX(NCHAR(254) COLLATE Latin1_General_Bin2, x.trans_info) + ), + implicit_tran = + CASE + WHEN x.implicit_tran = 1 THEN 'ON' + ELSE 'OFF' + END + FROM + ( + SELECT TOP(@i) + trans_nodes.trans_node.value('(session_id/text())[1]', 'SMALLINT') AS session_id, + COALESCE(trans_nodes.trans_node.value('(request_id/text())[1]', 'INT'), 0) AS request_id, + trans_nodes.trans_node.value('(implicit_tran/text())[1]', 'INT') AS implicit_tran, + trans_nodes.trans_node.value('(trans_info/text())[1]', 'NVARCHAR(4000)') AS trans_info + FROM + ( + SELECT TOP(@i) + CONVERT + ( + XML, + REPLACE + ( + CONVERT(NVARCHAR(MAX), trans_raw.trans_xml_raw) COLLATE Latin1_General_Bin2, + N'', N'' + ) + ) + FROM + ( + SELECT TOP(@i) + CASE u_trans.r + WHEN 1 THEN u_trans.session_id + ELSE NULL + END AS [session_id], + CASE u_trans.r + WHEN 1 THEN u_trans.request_id + ELSE NULL + END AS [request_id], + u_trans.implicit_tran AS [implicit_tran], + CONVERT + ( + NVARCHAR(MAX), + CASE + WHEN u_trans.database_id IS NOT NULL THEN + CASE u_trans.r + WHEN 1 THEN COALESCE(CONVERT(NVARCHAR, u_trans.transaction_start_time, 121) + NCHAR(254), N'') + ELSE N'' + END + + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + CONVERT(VARCHAR(128), COALESCE(DB_NAME(u_trans.database_id), N'(null)')), + NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?'),NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?'), + NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?'),NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?'),NCHAR(12),N'?'), + NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?'),NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?'), + NCHAR(0), + N'?' + ) + + N': ' + + CONVERT(NVARCHAR, u_trans.log_record_count) + N' (' + CONVERT(NVARCHAR, u_trans.log_kb_used) + N' kB)' + + N',' + ELSE + N'N/A,' + END COLLATE Latin1_General_Bin2 + ) AS [trans_info] + FROM + ( + SELECT TOP(@i) + trans.*, + ROW_NUMBER() OVER + ( + PARTITION BY + trans.session_id, + trans.request_id + ORDER BY + trans.transaction_start_time DESC + ) AS r + FROM + ( + SELECT TOP(@i) + session_tran_map.session_id, + session_tran_map.request_id, + s_tran.database_id, + COALESCE(SUM(s_tran.database_transaction_log_record_count), 0) AS log_record_count, + COALESCE(SUM(s_tran.database_transaction_log_bytes_used), 0) / 1024 AS log_kb_used, + MIN(s_tran.database_transaction_begin_time) AS transaction_start_time, + MAX + ( + CASE + WHEN a_tran.name = 'implicit_transaction' THEN 1 + ELSE 0 + END + ) AS implicit_tran + FROM + ( + SELECT TOP(@i) + * + FROM sys.dm_tran_active_transactions + WHERE + transaction_begin_time <= @last_collection_start + ) AS a_tran + INNER HASH JOIN + ( + SELECT TOP(@i) + * + FROM sys.dm_tran_database_transactions + WHERE + database_id < 32767 + ) AS s_tran ON + s_tran.transaction_id = a_tran.transaction_id + LEFT OUTER HASH JOIN + ( + SELECT TOP(@i) + * + FROM sys.dm_tran_session_transactions + ) AS tst ON + s_tran.transaction_id = tst.transaction_id + CROSS APPLY + ( + SELECT TOP(1) + s3.session_id, + s3.request_id + FROM + ( + SELECT TOP(1) + s1.session_id, + s1.request_id + FROM #sessions AS s1 + WHERE + s1.transaction_id = s_tran.transaction_id + AND s1.recursion = 1 + + UNION ALL + + SELECT TOP(1) + s2.session_id, + s2.request_id + FROM #sessions AS s2 + WHERE + s2.session_id = tst.session_id + AND s2.recursion = 1 + ) AS s3 + ORDER BY + s3.request_id + ) AS session_tran_map + GROUP BY + session_tran_map.session_id, + session_tran_map.request_id, + s_tran.database_id + ) AS trans + ) AS u_trans + FOR XML + PATH('trans'), + TYPE + ) AS trans_raw (trans_xml_raw) + ) AS trans_final (trans_xml) + CROSS APPLY trans_final.trans_xml.nodes('/trans') AS trans_nodes (trans_node) + ) AS x + INNER HASH JOIN #sessions AS s ON + s.session_id = x.session_id + AND s.request_id = x.request_id + OPTION (OPTIMIZE FOR (@i = 1)); + END; + + --Variables for text and plan collection + DECLARE + @session_id SMALLINT, + @request_id INT, + @sql_handle VARBINARY(64), + @plan_handle VARBINARY(64), + @statement_start_offset INT, + @statement_end_offset INT, + @start_time DATETIME, + @database_name sysname; + + IF + @recursion = 1 + AND @output_column_list LIKE '%|[sql_text|]%' ESCAPE '|' + BEGIN; + DECLARE sql_cursor + CURSOR LOCAL FAST_FORWARD + FOR + SELECT + session_id, + request_id, + sql_handle, + statement_start_offset, + statement_end_offset + FROM #sessions + WHERE + recursion = 1 + AND sql_handle IS NOT NULL + OPTION (KEEPFIXED PLAN); + + OPEN sql_cursor; + + FETCH NEXT FROM sql_cursor + INTO + @session_id, + @request_id, + @sql_handle, + @statement_start_offset, + @statement_end_offset; + + --Wait up to 5 ms for the SQL text, then give up + SET LOCK_TIMEOUT 5; + + WHILE @@FETCH_STATUS = 0 + BEGIN; + BEGIN TRY; + UPDATE s + SET + s.sql_text = + ( + SELECT + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + N'--' + NCHAR(13) + NCHAR(10) + + CASE + WHEN @get_full_inner_text = 1 THEN est.text + WHEN LEN(est.text) < (@statement_end_offset / 2) + 1 THEN est.text + WHEN SUBSTRING(est.text, (@statement_start_offset/2), 2) LIKE N'[a-zA-Z0-9][a-zA-Z0-9]' THEN est.text + ELSE + CASE + WHEN @statement_start_offset > 0 THEN + SUBSTRING + ( + est.text, + ((@statement_start_offset/2) + 1), + ( + CASE + WHEN @statement_end_offset = -1 THEN 2147483647 + ELSE ((@statement_end_offset - @statement_start_offset)/2) + 1 + END + ) + ) + ELSE RTRIM(LTRIM(est.text)) + END + END + + NCHAR(13) + NCHAR(10) + N'--' COLLATE Latin1_General_Bin2, + NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?'),NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?'), + NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?'),NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?'),NCHAR(12),N'?'), + NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?'),NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?'), + NCHAR(0), + N'' + ) AS [processing-instruction(query)] + FOR XML + PATH(''), + TYPE + ), + s.statement_start_offset = + CASE + WHEN LEN(est.text) < (@statement_end_offset / 2) + 1 THEN 0 + WHEN SUBSTRING(CONVERT(VARCHAR(MAX), est.text), (@statement_start_offset/2), 2) LIKE '[a-zA-Z0-9][a-zA-Z0-9]' THEN 0 + ELSE @statement_start_offset + END, + s.statement_end_offset = + CASE + WHEN LEN(est.text) < (@statement_end_offset / 2) + 1 THEN -1 + WHEN SUBSTRING(CONVERT(VARCHAR(MAX), est.text), (@statement_start_offset/2), 2) LIKE '[a-zA-Z0-9][a-zA-Z0-9]' THEN -1 + ELSE @statement_end_offset + END + FROM + #sessions AS s, + ( + SELECT TOP(1) + text + FROM + ( + SELECT + text, + 0 AS row_num + FROM sys.dm_exec_sql_text(@sql_handle) + + UNION ALL + + SELECT + NULL, + 1 AS row_num + ) AS est0 + ORDER BY + row_num + ) AS est + WHERE + s.session_id = @session_id + AND s.request_id = @request_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + END TRY + BEGIN CATCH; + UPDATE s + SET + s.sql_text = + CASE ERROR_NUMBER() + WHEN 1222 THEN '' + ELSE '' + END + FROM #sessions AS s + WHERE + s.session_id = @session_id + AND s.request_id = @request_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + END CATCH; + + FETCH NEXT FROM sql_cursor + INTO + @session_id, + @request_id, + @sql_handle, + @statement_start_offset, + @statement_end_offset; + END; + + --Return this to the default + SET LOCK_TIMEOUT -1; + + CLOSE sql_cursor; + DEALLOCATE sql_cursor; + END; + + IF + @get_outer_command = 1 + AND @recursion = 1 + AND @output_column_list LIKE '%|[sql_command|]%' ESCAPE '|' + BEGIN; + DECLARE @buffer_results TABLE + ( + EventType VARCHAR(30), + Parameters INT, + EventInfo NVARCHAR(4000), + start_time DATETIME, + session_number INT IDENTITY(1,1) NOT NULL PRIMARY KEY + ); + + DECLARE buffer_cursor + CURSOR LOCAL FAST_FORWARD + FOR + SELECT + session_id, + MAX(start_time) AS start_time + FROM #sessions + WHERE + recursion = 1 + GROUP BY + session_id + ORDER BY + session_id + OPTION (KEEPFIXED PLAN); + + OPEN buffer_cursor; + + FETCH NEXT FROM buffer_cursor + INTO + @session_id, + @start_time; + + WHILE @@FETCH_STATUS = 0 + BEGIN; + BEGIN TRY; + --In SQL Server 2008, DBCC INPUTBUFFER will throw + --an exception if the session no longer exists + INSERT @buffer_results + ( + EventType, + Parameters, + EventInfo + ) + EXEC sp_executesql + N'DBCC INPUTBUFFER(@session_id) WITH NO_INFOMSGS;', + N'@session_id SMALLINT', + @session_id; + + UPDATE br + SET + br.start_time = @start_time + FROM @buffer_results AS br + WHERE + br.session_number = + ( + SELECT MAX(br2.session_number) + FROM @buffer_results br2 + ); + END TRY + BEGIN CATCH + END CATCH; + + FETCH NEXT FROM buffer_cursor + INTO + @session_id, + @start_time; + END; + + UPDATE s + SET + sql_command = + ( + SELECT + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + CONVERT + ( + NVARCHAR(MAX), + N'--' + NCHAR(13) + NCHAR(10) + br.EventInfo + NCHAR(13) + NCHAR(10) + N'--' COLLATE Latin1_General_Bin2 + ), + NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?'),NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?'), + NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?'),NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?'),NCHAR(12),N'?'), + NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?'),NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?'), + NCHAR(0), + N'' + ) AS [processing-instruction(query)] + FROM @buffer_results AS br + WHERE + br.session_number = s.session_number + AND br.start_time = s.start_time + AND + ( + ( + s.start_time = s.last_request_start_time + AND EXISTS + ( + SELECT * + FROM sys.dm_exec_requests r2 + WHERE + r2.session_id = s.session_id + AND r2.request_id = s.request_id + AND r2.start_time = s.start_time + ) + ) + OR + ( + s.request_id = 0 + AND EXISTS + ( + SELECT * + FROM sys.dm_exec_sessions s2 + WHERE + s2.session_id = s.session_id + AND s2.last_request_start_time = s.last_request_start_time + ) + ) + ) + FOR XML + PATH(''), + TYPE + ) + FROM #sessions AS s + WHERE + recursion = 1 + OPTION (KEEPFIXED PLAN); + + CLOSE buffer_cursor; + DEALLOCATE buffer_cursor; + END; + + IF + @get_plans >= 1 + AND @recursion = 1 + AND @output_column_list LIKE '%|[query_plan|]%' ESCAPE '|' + BEGIN; + DECLARE @live_plan BIT; + SET @live_plan = ISNULL(CONVERT(BIT, SIGN(OBJECT_ID('sys.dm_exec_query_statistics_xml'))), 0) + + DECLARE plan_cursor + CURSOR LOCAL FAST_FORWARD + FOR + SELECT + session_id, + request_id, + plan_handle, + statement_start_offset, + statement_end_offset + FROM #sessions + WHERE + recursion = 1 + AND plan_handle IS NOT NULL + OPTION (KEEPFIXED PLAN); + + OPEN plan_cursor; + + FETCH NEXT FROM plan_cursor + INTO + @session_id, + @request_id, + @plan_handle, + @statement_start_offset, + @statement_end_offset; + + --Wait up to 5 ms for a query plan, then give up + SET LOCK_TIMEOUT 5; + + WHILE @@FETCH_STATUS = 0 + BEGIN; + DECLARE @query_plan XML; + SET @query_plan = NULL; + + IF @live_plan = 1 + BEGIN; + BEGIN TRY; + SELECT + @query_plan = x.query_plan + FROM sys.dm_exec_query_statistics_xml(@session_id) AS x; + + IF + @query_plan IS NOT NULL + AND EXISTS + ( + SELECT + * + FROM sys.dm_exec_requests AS r + WHERE + r.session_id = @session_id + AND r.request_id = @request_id + AND r.plan_handle = @plan_handle + AND r.statement_start_offset = @statement_start_offset + AND r.statement_end_offset = @statement_end_offset + ) + BEGIN; + UPDATE s + SET + s.query_plan = @query_plan + FROM #sessions AS s + WHERE + s.session_id = @session_id + AND s.request_id = @request_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + END; + END TRY + BEGIN CATCH; + SET @query_plan = NULL; + END CATCH; + END; + + IF @query_plan IS NULL + BEGIN; + BEGIN TRY; + UPDATE s + SET + s.query_plan = + ( + SELECT + CONVERT(xml, query_plan) + FROM sys.dm_exec_text_query_plan + ( + @plan_handle, + CASE @get_plans + WHEN 1 THEN + @statement_start_offset + ELSE + 0 + END, + CASE @get_plans + WHEN 1 THEN + @statement_end_offset + ELSE + -1 + END + ) + ) + FROM #sessions AS s + WHERE + s.session_id = @session_id + AND s.request_id = @request_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + END TRY + BEGIN CATCH; + IF ERROR_NUMBER() = 6335 + BEGIN; + UPDATE s + SET + s.query_plan = + ( + SELECT + N'--' + NCHAR(13) + NCHAR(10) + + N'-- Could not render showplan due to XML data type limitations. ' + NCHAR(13) + NCHAR(10) + + N'-- To see the graphical plan save the XML below as a .SQLPLAN file and re-open in SSMS.' + NCHAR(13) + NCHAR(10) + + N'--' + NCHAR(13) + NCHAR(10) + + REPLACE(qp.query_plan, N'' + ELSE '' + END + FROM #sessions AS s + WHERE + s.session_id = @session_id + AND s.request_id = @request_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + END; + END CATCH; + END; + + FETCH NEXT FROM plan_cursor + INTO + @session_id, + @request_id, + @plan_handle, + @statement_start_offset, + @statement_end_offset; + END; + + --Return this to the default + SET LOCK_TIMEOUT -1; + + CLOSE plan_cursor; + DEALLOCATE plan_cursor; + END; + + IF + @get_locks = 1 + AND @recursion = 1 + AND @output_column_list LIKE '%|[locks|]%' ESCAPE '|' + BEGIN; + DECLARE locks_cursor + CURSOR LOCAL FAST_FORWARD + FOR + SELECT DISTINCT + database_name + FROM #locks + WHERE + EXISTS + ( + SELECT * + FROM #sessions AS s + WHERE + s.session_id = #locks.session_id + AND recursion = 1 + ) + AND database_name <> '(null)' + OPTION (KEEPFIXED PLAN); + + OPEN locks_cursor; + + FETCH NEXT FROM locks_cursor + INTO + @database_name; + + WHILE @@FETCH_STATUS = 0 + BEGIN; + BEGIN TRY; + SET @sql_n = CONVERT(NVARCHAR(MAX), N'') + N' + UPDATE l + SET + object_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + o.name COLLATE Latin1_General_Bin2, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ), + index_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + i.name COLLATE Latin1_General_Bin2, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ), + schema_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + s.name COLLATE Latin1_General_Bin2, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ), + principal_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + dp.name COLLATE Latin1_General_Bin2, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ) + FROM #locks AS l + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.allocation_units AS au ON + au.allocation_unit_id = l.allocation_unit_id + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.partitions AS p ON + p.hobt_id = + COALESCE + ( + l.hobt_id, + CASE + WHEN au.type IN (1, 3) THEN au.container_id + ELSE NULL + END + ) + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.partitions AS p1 ON + l.hobt_id IS NULL + AND au.type = 2 + AND p1.partition_id = au.container_id + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.objects AS o ON + o.object_id = COALESCE(l.object_id, p.object_id, p1.object_id) + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.indexes AS i ON + i.object_id = COALESCE(l.object_id, p.object_id, p1.object_id) + AND i.index_id = COALESCE(l.index_id, p.index_id, p1.index_id) + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.schemas AS s ON + s.schema_id = COALESCE(l.schema_id, o.schema_id) + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.database_principals AS dp ON + dp.principal_id = l.principal_id + WHERE + l.database_name = @database_name + OPTION (KEEPFIXED PLAN); '; + + EXEC sp_executesql + @sql_n, + N'@database_name sysname', + @database_name; + END TRY + BEGIN CATCH; + UPDATE #locks + SET + query_error = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + CONVERT + ( + NVARCHAR(MAX), + ERROR_MESSAGE() COLLATE Latin1_General_Bin2 + ), + NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?'),NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?'), + NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?'),NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?'),NCHAR(12),N'?'), + NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?'),NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?'), + NCHAR(0), + N'' + ) + WHERE + database_name = @database_name + OPTION (KEEPFIXED PLAN); + END CATCH; + + FETCH NEXT FROM locks_cursor + INTO + @database_name; + END; + + CLOSE locks_cursor; + DEALLOCATE locks_cursor; + + CREATE CLUSTERED INDEX IX_SRD ON #locks (session_id, request_id, database_name); + + UPDATE s + SET + s.locks = + ( + SELECT + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + CONVERT + ( + NVARCHAR(MAX), + l1.database_name COLLATE Latin1_General_Bin2 + ), + NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?'),NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?'), + NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?'),NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?'),NCHAR(12),N'?'), + NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?'),NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?'), + NCHAR(0), + N'' + ) AS [Database/@name], + MIN(l1.query_error) AS [Database/@query_error], + ( + SELECT + l2.request_mode AS [Lock/@request_mode], + l2.request_status AS [Lock/@request_status], + COUNT(*) AS [Lock/@request_count] + FROM #locks AS l2 + WHERE + l1.session_id = l2.session_id + AND l1.request_id = l2.request_id + AND l2.database_name = l1.database_name + AND l2.resource_type = 'DATABASE' + GROUP BY + l2.request_mode, + l2.request_status + FOR XML + PATH(''), + TYPE + ) AS [Database/Locks], + ( + SELECT + COALESCE(l3.object_name, '(null)') AS [Object/@name], + l3.schema_name AS [Object/@schema_name], + ( + SELECT + l4.resource_type AS [Lock/@resource_type], + l4.page_type AS [Lock/@page_type], + l4.index_name AS [Lock/@index_name], + CASE + WHEN l4.object_name IS NULL THEN l4.schema_name + ELSE NULL + END AS [Lock/@schema_name], + l4.principal_name AS [Lock/@principal_name], + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + l4.resource_description COLLATE Latin1_General_Bin2, + NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?'),NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?'), + NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?'),NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?'),NCHAR(12),N'?'), + NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?'),NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?'), + NCHAR(0), + N'' + ) AS [Lock/@resource_description], + l4.request_mode AS [Lock/@request_mode], + l4.request_status AS [Lock/@request_status], + SUM(l4.request_count) AS [Lock/@request_count] + FROM #locks AS l4 + WHERE + l4.session_id = l3.session_id + AND l4.request_id = l3.request_id + AND l3.database_name = l4.database_name + AND COALESCE(l3.object_name, '(null)') = COALESCE(l4.object_name, '(null)') + AND COALESCE(l3.schema_name, '') = COALESCE(l4.schema_name, '') + AND l4.resource_type <> 'DATABASE' + GROUP BY + l4.resource_type, + l4.page_type, + l4.index_name, + CASE + WHEN l4.object_name IS NULL THEN l4.schema_name + ELSE NULL + END, + l4.principal_name, + l4.resource_description, + l4.request_mode, + l4.request_status + FOR XML + PATH(''), + TYPE + ) AS [Object/Locks] + FROM #locks AS l3 + WHERE + l3.session_id = l1.session_id + AND l3.request_id = l1.request_id + AND l3.database_name = l1.database_name + AND l3.resource_type <> 'DATABASE' + GROUP BY + l3.session_id, + l3.request_id, + l3.database_name, + COALESCE(l3.object_name, '(null)'), + l3.schema_name + FOR XML + PATH(''), + TYPE + ) AS [Database/Objects] + FROM #locks AS l1 + WHERE + l1.session_id = s.session_id + AND l1.request_id = s.request_id + AND l1.start_time IN (s.start_time, s.last_request_start_time) + AND s.recursion = 1 + GROUP BY + l1.session_id, + l1.request_id, + l1.database_name + FOR XML + PATH(''), + TYPE + ) + FROM #sessions s + OPTION (KEEPFIXED PLAN); + END; + + IF + @find_block_leaders = 1 + AND @recursion = 1 + AND @output_column_list LIKE '%|[blocked_session_count|]%' ESCAPE '|' + BEGIN; + WITH + blockers AS + ( + SELECT + session_id, + session_id AS top_level_session_id, + CONVERT(VARCHAR(8000), '.' + CONVERT(VARCHAR(8000), session_id) + '.') AS the_path + FROM #sessions + WHERE + recursion = 1 + + UNION ALL + + SELECT + s.session_id, + b.top_level_session_id, + CONVERT(VARCHAR(8000), b.the_path + CONVERT(VARCHAR(8000), s.session_id) + '.') AS the_path + FROM blockers AS b + JOIN #sessions AS s ON + s.blocking_session_id = b.session_id + AND s.recursion = 1 + AND b.the_path NOT LIKE '%.' + CONVERT(VARCHAR(8000), s.session_id) + '.%' COLLATE Latin1_General_Bin2 + ) + UPDATE s + SET + s.blocked_session_count = x.blocked_session_count + FROM #sessions AS s + JOIN + ( + SELECT + b.top_level_session_id AS session_id, + COUNT(*) - 1 AS blocked_session_count + FROM blockers AS b + GROUP BY + b.top_level_session_id + ) x ON + s.session_id = x.session_id + WHERE + s.recursion = 1; + END; + + IF + @get_task_info = 2 + AND @output_column_list LIKE '%|[additional_info|]%' ESCAPE '|' + AND @recursion = 1 + BEGIN; + CREATE TABLE #blocked_requests + ( + session_id SMALLINT NOT NULL, + request_id INT NOT NULL, + database_name sysname NOT NULL, + object_id INT, + hobt_id BIGINT, + schema_id INT, + schema_name sysname NULL, + object_name sysname NULL, + query_error NVARCHAR(2048), + PRIMARY KEY (database_name, session_id, request_id) + ); + + CREATE STATISTICS s_database_name ON #blocked_requests (database_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_schema_name ON #blocked_requests (schema_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_object_name ON #blocked_requests (object_name) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + CREATE STATISTICS s_query_error ON #blocked_requests (query_error) + WITH SAMPLE 0 ROWS, NORECOMPUTE; + + INSERT #blocked_requests + ( + session_id, + request_id, + database_name, + object_id, + hobt_id, + schema_id + ) + SELECT + session_id, + request_id, + database_name, + object_id, + hobt_id, + CONVERT(INT, SUBSTRING(schema_node, CHARINDEX(' = ', schema_node) + 3, LEN(schema_node))) AS schema_id + FROM + ( + SELECT + session_id, + request_id, + agent_nodes.agent_node.value('(database_name/text())[1]', 'sysname') AS database_name, + agent_nodes.agent_node.value('(object_id/text())[1]', 'int') AS object_id, + agent_nodes.agent_node.value('(hobt_id/text())[1]', 'bigint') AS hobt_id, + agent_nodes.agent_node.value('(metadata_resource/text()[.="SCHEMA"]/../../metadata_class_id/text())[1]', 'varchar(100)') AS schema_node + FROM #sessions AS s + CROSS APPLY s.additional_info.nodes('//block_info') AS agent_nodes (agent_node) + WHERE + s.recursion = 1 + ) AS t + WHERE + t.database_name IS NOT NULL + AND + ( + t.object_id IS NOT NULL + OR t.hobt_id IS NOT NULL + OR t.schema_node IS NOT NULL + ); + + DECLARE blocks_cursor + CURSOR LOCAL FAST_FORWARD + FOR + SELECT DISTINCT + database_name + FROM #blocked_requests; + + OPEN blocks_cursor; + + FETCH NEXT FROM blocks_cursor + INTO + @database_name; + + WHILE @@FETCH_STATUS = 0 + BEGIN; + BEGIN TRY; + SET @sql_n = + CONVERT(NVARCHAR(MAX), N'') + N' + UPDATE b + SET + b.schema_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + s.name COLLATE Latin1_General_Bin2, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ), + b.object_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + o.name COLLATE Latin1_General_Bin2, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N'''' + ) + FROM #blocked_requests AS b + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.partitions AS p ON + p.hobt_id = b.hobt_id + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.objects AS o ON + o.object_id = COALESCE(p.object_id, b.object_id) + LEFT OUTER JOIN ' + QUOTENAME(@database_name) + N'.sys.schemas AS s ON + s.schema_id = COALESCE(o.schema_id, b.schema_id) + WHERE + b.database_name = @database_name; '; + + EXEC sp_executesql + @sql_n, + N'@database_name sysname', + @database_name; + END TRY + BEGIN CATCH; + UPDATE #blocked_requests + SET + query_error = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + CONVERT + ( + NVARCHAR(MAX), + ERROR_MESSAGE() COLLATE Latin1_General_Bin2 + ), + NCHAR(31),N'?'),NCHAR(30),N'?'),NCHAR(29),N'?'),NCHAR(28),N'?'),NCHAR(27),N'?'),NCHAR(26),N'?'),NCHAR(25),N'?'),NCHAR(24),N'?'),NCHAR(23),N'?'),NCHAR(22),N'?'), + NCHAR(21),N'?'),NCHAR(20),N'?'),NCHAR(19),N'?'),NCHAR(18),N'?'),NCHAR(17),N'?'),NCHAR(16),N'?'),NCHAR(15),N'?'),NCHAR(14),N'?'),NCHAR(12),N'?'), + NCHAR(11),N'?'),NCHAR(8),N'?'),NCHAR(7),N'?'),NCHAR(6),N'?'),NCHAR(5),N'?'),NCHAR(4),N'?'),NCHAR(3),N'?'),NCHAR(2),N'?'),NCHAR(1),N'?'), + NCHAR(0), + N'' + ) + WHERE + database_name = @database_name; + END CATCH; + + FETCH NEXT FROM blocks_cursor + INTO + @database_name; + END; + + CLOSE blocks_cursor; + DEALLOCATE blocks_cursor; + + UPDATE s + SET + additional_info.modify + (' + insert {sql:column("b.schema_name")} + as last + into (/additional_info/block_info)[1] + ') + FROM #sessions AS s + INNER JOIN #blocked_requests AS b ON + b.session_id = s.session_id + AND b.request_id = s.request_id + AND s.recursion = 1 + WHERE + b.schema_name IS NOT NULL; + + UPDATE s + SET + additional_info.modify + (' + insert {sql:column("b.object_name")} + as last + into (/additional_info/block_info)[1] + ') + FROM #sessions AS s + INNER JOIN #blocked_requests AS b ON + b.session_id = s.session_id + AND b.request_id = s.request_id + AND s.recursion = 1 + WHERE + b.object_name IS NOT NULL; + + UPDATE s + SET + additional_info.modify + (' + insert {sql:column("b.query_error")} + as last + into (/additional_info/block_info)[1] + ') + FROM #sessions AS s + INNER JOIN #blocked_requests AS b ON + b.session_id = s.session_id + AND b.request_id = s.request_id + AND s.recursion = 1 + WHERE + b.query_error IS NOT NULL; + END; + + IF + @output_column_list LIKE '%|[program_name|]%' ESCAPE '|' + AND @output_column_list LIKE '%|[additional_info|]%' ESCAPE '|' + AND @recursion = 1 + AND DB_ID('msdb') IS NOT NULL + BEGIN; + SET @sql_n = + N'BEGIN TRY; + DECLARE @job_name sysname; + SET @job_name = NULL; + DECLARE @step_name sysname; + SET @step_name = NULL; + + SELECT + @job_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + j.name, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N''?'' + ), + @step_name = + REPLACE + ( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + s.step_name, + NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''), + NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''), + NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''), + NCHAR(0), + N''?'' + ) + FROM msdb.dbo.sysjobs AS j + INNER JOIN msdb.dbo.sysjobsteps AS s ON + j.job_id = s.job_id + WHERE + j.job_id = @job_id + AND s.step_id = @step_id; + + IF @job_name IS NOT NULL + BEGIN; + UPDATE s + SET + additional_info.modify + ('' + insert text{sql:variable("@job_name")} + into (/additional_info/agent_job_info/job_name)[1] + '') + FROM #sessions AS s + WHERE + s.session_id = @session_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + + UPDATE s + SET + additional_info.modify + ('' + insert text{sql:variable("@step_name")} + into (/additional_info/agent_job_info/step_name)[1] + '') + FROM #sessions AS s + WHERE + s.session_id = @session_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + END; + END TRY + BEGIN CATCH; + DECLARE @msdb_error_message NVARCHAR(256); + SET @msdb_error_message = ERROR_MESSAGE(); + + UPDATE s + SET + additional_info.modify + ('' + insert {sql:variable("@msdb_error_message")} + as last + into (/additional_info/agent_job_info)[1] + '') + FROM #sessions AS s + WHERE + s.session_id = @session_id + AND s.recursion = 1 + OPTION (KEEPFIXED PLAN); + END CATCH;' + + DECLARE @job_id UNIQUEIDENTIFIER; + DECLARE @step_id INT; + + DECLARE agent_cursor + CURSOR LOCAL FAST_FORWARD + FOR + SELECT + s.session_id, + agent_nodes.agent_node.value('(job_id/text())[1]', 'uniqueidentifier') AS job_id, + agent_nodes.agent_node.value('(step_id/text())[1]', 'int') AS step_id + FROM #sessions AS s + CROSS APPLY s.additional_info.nodes('//agent_job_info') AS agent_nodes (agent_node) + WHERE + s.recursion = 1 + OPTION (KEEPFIXED PLAN); + + OPEN agent_cursor; + + FETCH NEXT FROM agent_cursor + INTO + @session_id, + @job_id, + @step_id; + + WHILE @@FETCH_STATUS = 0 + BEGIN; + EXEC sp_executesql + @sql_n, + N'@job_id UNIQUEIDENTIFIER, @step_id INT, @session_id SMALLINT', + @job_id, @step_id, @session_id + + FETCH NEXT FROM agent_cursor + INTO + @session_id, + @job_id, + @step_id; + END; + + CLOSE agent_cursor; + DEALLOCATE agent_cursor; + END; + + IF + @delta_interval > 0 + AND @recursion <> 1 + BEGIN; + SET @recursion = 1; + + DECLARE @delay_time CHAR(12); + SET @delay_time = CONVERT(VARCHAR, DATEADD(second, @delta_interval, 0), 114); + WAITFOR DELAY @delay_time; + + GOTO REDO; + END; + END; + + DECLARE + @num_data_threshold MONEY, + @num_col_fmt NVARCHAR(MAX), + @num_delta_col_fmt NVARCHAR(MAX); + + SET @num_data_threshold = 919919919919919; + SET @num_col_fmt = + CASE @format_output + WHEN 1 THEN N' + CONVERT(VARCHAR, SPACE(MAX(LEN(CONVERT(VARCHAR, [col_name]))) OVER() - LEN(CONVERT(VARCHAR, [col_name]))) + LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN [col_name] > @num_data_threshold THEN @num_data_threshold ELSE [col_name] END), 1), 19)) AS ' + WHEN 2 THEN N' + CONVERT(VARCHAR, LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN [col_name] > @num_data_threshold THEN @num_data_threshold ELSE [col_name] END), 1), 19)) AS ' + ELSE N'' + END + N'[col_name], '; + SET @num_delta_col_fmt = + N' + CASE + WHEN + first_request_start_time = last_request_start_time + AND num_events = 2 + AND [col_name] >= 0 + THEN ' + + CASE @format_output + WHEN 1 THEN N'CONVERT(VARCHAR, SPACE(MAX(LEN(CONVERT(VARCHAR, [col_name]))) OVER() - LEN(CONVERT(VARCHAR, [col_name]))) + LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN [col_name] > @num_data_threshold THEN @num_data_threshold ELSE [col_name] END), 1), 19)) ' + WHEN 2 THEN N'CONVERT(VARCHAR, LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN [col_name] > @num_data_threshold THEN @num_data_threshold ELSE [col_name] END), 1), 19)) ' + ELSE N'[col_name] ' + END + N' + ELSE NULL + END AS [col_name], '; + + SET @sql_n = CONVERT(NVARCHAR(MAX), N'') + + --Outer column list + CASE + WHEN + @destination_table <> '' + AND @return_schema = 0 + THEN N'INSERT ' + @destination_table + ' ' + ELSE N'' + END + + N'SELECT ' + + @output_column_list + N' ' + + CASE @return_schema + WHEN 1 THEN N'INTO #session_schema ' + ELSE N'' + END + --End outer column list + + + --Inner column list + N' + FROM + ( + SELECT + session_id, ' + + --[dd hh:mm:ss.mss] + CASE + WHEN @format_output IN (1, 2) THEN + N' + CASE + WHEN elapsed_time < 0 THEN + RIGHT + ( + REPLICATE(''0'', max_elapsed_length) + CONVERT(VARCHAR, (-1 * elapsed_time) / 86400), + max_elapsed_length + ) + + RIGHT + ( + CONVERT(VARCHAR, DATEADD(second, (-1 * elapsed_time), 0), 120), + 9 + ) + + ''.000'' + ELSE + RIGHT + ( + REPLICATE(''0'', max_elapsed_length) + CONVERT(VARCHAR, elapsed_time / 86400000), + max_elapsed_length + ) + + RIGHT + ( + CONVERT(VARCHAR, DATEADD(second, elapsed_time / 1000, 0), 120), + 9 + ) + + ''.'' + + RIGHT(''000'' + CONVERT(VARCHAR, elapsed_time % 1000), 3) + END AS [dd hh:mm:ss.mss], ' + ELSE + N'' + END + + --[dd hh:mm:ss.mss (avg)] / avg_elapsed_time + CASE + WHEN @format_output IN (1, 2) THEN + N' + RIGHT + ( + ''00'' + CONVERT(VARCHAR, avg_elapsed_time / 86400000), + 2 + ) + + RIGHT + ( + CONVERT(VARCHAR, DATEADD(second, avg_elapsed_time / 1000, 0), 120), + 9 + ) + + ''.'' + + RIGHT(''000'' + CONVERT(VARCHAR, avg_elapsed_time % 1000), 3) AS [dd hh:mm:ss.mss (avg)], ' + ELSE + N'avg_elapsed_time, ' + END + + REPLACE(@num_col_fmt, N'[col_name]', N'physical_io') + + REPLACE(@num_col_fmt, N'[col_name]', N'reads') + + REPLACE(@num_col_fmt, N'[col_name]', N'physical_reads') + + REPLACE(@num_col_fmt, N'[col_name]', N'writes') + + REPLACE(@num_col_fmt, N'[col_name]', N'tempdb_allocations') + + REPLACE(@num_col_fmt, N'[col_name]', N'tempdb_current') + + REPLACE(@num_col_fmt, N'[col_name]', N'CPU') + + REPLACE(@num_col_fmt, N'[col_name]', N'context_switches') + + REPLACE(@num_col_fmt, N'[col_name]', N'used_memory') + + REPLACE(@num_col_fmt, N'[col_name]', N'max_used_memory') + + REPLACE(@num_col_fmt, N'[col_name]', N'requested_memory') + + REPLACE(@num_col_fmt, N'[col_name]', N'granted_memory') + + CASE + WHEN @output_column_list LIKE '%|_delta|]%' ESCAPE '|' THEN + REPLACE(@num_delta_col_fmt, N'[col_name]', N'physical_io_delta') + + REPLACE(@num_delta_col_fmt, N'[col_name]', N'reads_delta') + + REPLACE(@num_delta_col_fmt, N'[col_name]', N'physical_reads_delta') + + REPLACE(@num_delta_col_fmt, N'[col_name]', N'writes_delta') + + REPLACE(@num_delta_col_fmt, N'[col_name]', N'tempdb_allocations_delta') + + --this is the only one that can (legitimately) go negative + REPLACE(@num_delta_col_fmt, N'[col_name]', N'tempdb_current_delta') + + --CPU_delta + --leaving this one hardcoded, as there is a bit of different interaction here + N' + CASE + WHEN + first_request_start_time = last_request_start_time + AND num_events = 2 + THEN + CASE + WHEN + thread_CPU_delta > CPU_delta + AND thread_CPU_delta > 0 + THEN ' + + CASE @format_output + WHEN 1 THEN N'CONVERT(VARCHAR, SPACE(MAX(LEN(CONVERT(VARCHAR, thread_CPU_delta + CPU_delta))) OVER() - LEN(CONVERT(VARCHAR, thread_CPU_delta))) + LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN thread_CPU_delta > @num_data_threshold THEN @num_data_threshold ELSE thread_CPU_delta END), 1), 19)) ' + WHEN 2 THEN N'CONVERT(VARCHAR, LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN thread_CPU_delta > @num_data_threshold THEN @num_data_threshold ELSE thread_CPU_delta END), 1), 19)) ' + ELSE N'thread_CPU_delta ' + END + N' + WHEN CPU_delta >= 0 THEN ' + + CASE @format_output + WHEN 1 THEN N'CONVERT(VARCHAR, SPACE(MAX(LEN(CONVERT(VARCHAR, thread_CPU_delta + CPU_delta))) OVER() - LEN(CONVERT(VARCHAR, CPU_delta))) + LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN CPU_delta > @num_data_threshold THEN @num_data_threshold ELSE CPU_delta END), 1), 19)) ' + WHEN 2 THEN N'CONVERT(VARCHAR, LEFT(CONVERT(CHAR(22), CONVERT(MONEY, CASE WHEN CPU_delta > @num_data_threshold THEN @num_data_threshold ELSE CPU_delta END), 1), 19)) ' + ELSE N'CPU_delta ' + END + N' + ELSE NULL + END + ELSE + NULL + END AS CPU_delta, ' + + REPLACE(@num_delta_col_fmt, N'[col_name]', N'context_switches_delta') + + REPLACE(@num_delta_col_fmt, N'[col_name]', N'used_memory_delta') + + REPLACE(@num_delta_col_fmt, N'[col_name]', N'max_used_memory_delta') + ELSE N'' + END + N' + ' + + REPLACE(@num_col_fmt, N'[col_name]', N'tasks') + N' + status, + wait_info, + locks, + tran_start_time, + LEFT(tran_log_writes, LEN(tran_log_writes) - 1) AS tran_log_writes, + implicit_tran, ' + + REPLACE(@num_col_fmt, '[col_name]', 'open_tran_count') + N' + ' + + --sql_command + CASE @format_output + WHEN 0 THEN N'REPLACE(REPLACE(CONVERT(NVARCHAR(MAX), sql_command), '''', '''') AS ' + ELSE N'' + END + N'sql_command, + ' + + --sql_text + CASE @format_output + WHEN 0 THEN N'REPLACE(REPLACE(CONVERT(NVARCHAR(MAX), sql_text), '''', '''') AS ' + ELSE N'' + END + N'sql_text, + query_plan, + blocking_session_id, ' + + REPLACE(@num_col_fmt, N'[col_name]', N'blocked_session_count') + + REPLACE(@num_col_fmt, N'[col_name]', N'percent_complete') + N' + host_name, + login_name, + database_name, + program_name, + additional_info, + memory_info, + start_time, + login_time, + CASE + WHEN status = N''sleeping'' THEN NULL + ELSE request_id + END AS request_id, + GETDATE() AS collection_time ' + --End inner column list + + + --Derived table and INSERT specification + N' + FROM + ( + SELECT TOP(2147483647) + *, + CASE + MAX + ( + LEN + ( + CONVERT + ( + VARCHAR, + CASE + WHEN elapsed_time < 0 THEN + (-1 * elapsed_time) / 86400 + ELSE + elapsed_time / 86400000 + END + ) + ) + ) OVER () + WHEN 1 THEN 2 + ELSE + MAX + ( + LEN + ( + CONVERT + ( + VARCHAR, + CASE + WHEN elapsed_time < 0 THEN + (-1 * elapsed_time) / 86400 + ELSE + elapsed_time / 86400000 + END + ) + ) + ) OVER () + END AS max_elapsed_length, ' + + CASE + WHEN @output_column_list LIKE '%|_delta|]%' ESCAPE '|' THEN + N' + MAX(physical_io * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(physical_io * recursion) OVER (PARTITION BY session_id, request_id) AS physical_io_delta, + MAX(reads * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(reads * recursion) OVER (PARTITION BY session_id, request_id) AS reads_delta, + MAX(physical_reads * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(physical_reads * recursion) OVER (PARTITION BY session_id, request_id) AS physical_reads_delta, + MAX(writes * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(writes * recursion) OVER (PARTITION BY session_id, request_id) AS writes_delta, + MAX(tempdb_allocations * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(tempdb_allocations * recursion) OVER (PARTITION BY session_id, request_id) AS tempdb_allocations_delta, + MAX(tempdb_current * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(tempdb_current * recursion) OVER (PARTITION BY session_id, request_id) AS tempdb_current_delta, + MAX(CPU * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(CPU * recursion) OVER (PARTITION BY session_id, request_id) AS CPU_delta, + MAX(thread_CPU_snapshot * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(thread_CPU_snapshot * recursion) OVER (PARTITION BY session_id, request_id) AS thread_CPU_delta, + MAX(context_switches * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(context_switches * recursion) OVER (PARTITION BY session_id, request_id) AS context_switches_delta, + MAX(used_memory * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(used_memory * recursion) OVER (PARTITION BY session_id, request_id) AS used_memory_delta, + MAX(max_used_memory * recursion) OVER (PARTITION BY session_id, request_id) + + MIN(max_used_memory * recursion) OVER (PARTITION BY session_id, request_id) AS max_used_memory_delta, + MIN(last_request_start_time) OVER (PARTITION BY session_id, request_id) AS first_request_start_time, ' + ELSE N'' + END + N' + COUNT(*) OVER (PARTITION BY session_id, request_id) AS num_events + FROM #sessions AS s1 ' + + CASE + WHEN @sort_order = '' THEN N'' + ELSE + N' + ORDER BY ' + + CONVERT(NVARCHAR(MAX), @sort_order) + END + + N' + ) AS s + WHERE + s.recursion = 1 + ) x + OPTION (KEEPFIXED PLAN); + ' + + CASE @return_schema + WHEN 1 THEN + N' + SET @schema = + ''CREATE TABLE ( '' + + STUFF + ( + ( + SELECT + '','' + + QUOTENAME(COLUMN_NAME) + '' '' + + DATA_TYPE + + CASE + WHEN DATA_TYPE LIKE ''%char'' THEN ''('' + COALESCE(NULLIF(CONVERT(VARCHAR, CHARACTER_MAXIMUM_LENGTH), ''-1''), ''max'') + '') '' + ELSE '' '' + END + + CASE IS_NULLABLE + WHEN ''NO'' THEN ''NOT '' + ELSE '''' + END + ''NULL'' AS [text()] + FROM tempdb.INFORMATION_SCHEMA.COLUMNS + WHERE + TABLE_NAME = (SELECT name FROM tempdb.sys.objects WHERE object_id = OBJECT_ID(''tempdb..#session_schema'')) + ORDER BY + ORDINAL_POSITION + FOR XML + PATH('''') + ), + + 1, + 1, + '''' + ) + + '');''; ' + ELSE N'' + END; + --End derived table and INSERT specification + + EXEC sp_executesql + @sql_n, + N'@num_data_threshold MONEY, @schema VARCHAR(MAX) OUTPUT', + @num_data_threshold, @schema OUTPUT; +END; +GO + +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'; +GO + + +IF OBJECT_ID('dbo.sp_whoisactive') IS NOT NULL + DROP PROCEDURE dbo.sp_whoisactive; +GO + +/* +kill 111 +*/ \ No newline at end of file diff --git a/wac1.sql b/wac1.sql new file mode 100644 index 0000000..2931b9d --- /dev/null +++ b/wac1.sql @@ -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';