diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57a23a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/OCTPDBA-420 - migrate centrale test +/OCTPDBA-421 - migrate centrale prod +/OCTPDBA-422 - Migrate Central Integration +/OCTPDBA-417 - centrale prod sql installation diff --git a/DBG - GAIA - check routes after playoffs.sql b/DBG - GAIA - check routes after playoffs.sql new file mode 100644 index 0000000..33de7c0 --- /dev/null +++ b/DBG - GAIA - check routes after playoffs.sql @@ -0,0 +1,24 @@ +/* + +Routes after playoff's seems to be in the wrong domain. +We had the case at least with ama339, ama341 and ama337 where the address pointed to "amaXXX.coop-vitality.ch:4022", rather than "amaXXX.amavita.ch:4022" + +Use this script to check for inconsistencies and craft ALTER statement (from CVI to AMA or SUN, as those are the only occurences we have found until today ) +The reporting will be correct, but the ALTER logic might need to be adapted. +*/ +SELECT * , + 'alter route ['+r.[name]+'] WITH SERVICE_NAME = N'''+r.[remote_service_name]+''' , ADDRESS = N'''+REPLACE([r].[address] COLLATE SQL_Latin1_General_CP1_CI_AS, 'coop-vitality', 'amavita' )+'''; ' AS upd +FROM sys.[routes] r +WHERE name LIKE '%ama%' +AND [r].[address] NOT LIKE '%amavita.ch%' + +SELECT * , + 'alter route ['+r.[name]+'] WITH SERVICE_NAME = N'''+r.[remote_service_name]+''' , ADDRESS = N'''+REPLACE([r].[address] COLLATE SQL_Latin1_General_CP1_CI_AS, 'coop-vitality', 'sunstore' )+'''; ' AS upd +FROM sys.[routes] r +WHERE name LIKE '%sun%' +AND [r].[address] NOT LIKE '%sunstore.ch%' + +SELECT * +FROM sys.[routes] r +WHERE name LIKE '%cvi%' +AND [r].[address] NOT LIKE '%coop-vitality.ch%' diff --git a/DBG - Scripter les jobs.sql b/DBG - Scripter les jobs.sql index 1b78b7c..7021db3 100644 --- a/DBG - Scripter les jobs.sql +++ b/DBG - Scripter les jobs.sql @@ -62,14 +62,16 @@ DECLARE @job_id UNIQUEIDENTIFIER = NULL, @code_job NVARCHAR(10) = NULL DECLARE c_jobs CURSOR LOCAL FORWARD_ONLY STATIC FOR - SELECT 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 - FROM msdb.dbo.sysjobs -WHERE LOWER(name) NOT LIKE '%distribution%' - AND LOWER(name) NOT LIKE '%subscription%' - AND LOWER(name) NOT LIKE '%replication%' - AND LOWER(name) NOT LIKE '%ActivePos_read-%' - AND name LIKE '%-%' - ORDER BY name + 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 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%' + ORDER BY sj.name OPEN c_jobs @@ -80,7 +82,7 @@ FETCH NEXT FROM c_jobs WHILE @@fetch_status = 0 BEGIN - SET @path = 'D:\dbJobs\'+@name+'.sql' + SET @path = 'D:\dev\'+@name+'.sql' DECLARE @cleanCmd VARCHAR(8000)= 'del "'+@path+'"'; DECLARE @catchOutput TABLE(output VARCHAR(max)); @@ -204,7 +206,7 @@ BEGIN '@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(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) @@ -224,7 +226,8 @@ BEGIN 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='+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) diff --git a/DBG - check assemblies signature.sql b/DBG - check assemblies signature.sql new file mode 100644 index 0000000..2fc7f9d --- /dev/null +++ b/DBG - check assemblies signature.sql @@ -0,0 +1,7 @@ +use [Arizona] + +SELECT + CAST(ISNULL(ASSEMBLYPROPERTY(a.name, N'PublicKey'), CONVERT(varbinary(8000), N'')) AS varbinary(8000)) AS [PublicKey] + ,* +FROM sys.[assemblies] [a] +WHERE [a].[is_user_defined] = 1 \ No newline at end of file diff --git a/DBG - cleanup gaia for 1 phcy_code.sql b/DBG - cleanup gaia for 1 phcy_code.sql new file mode 100644 index 0000000..c3699ad --- /dev/null +++ b/DBG - cleanup gaia for 1 phcy_code.sql @@ -0,0 +1,8 @@ +USE [Gaia] + +SELECT 'delete from ['+c.[TABLE_SCHEMA]+'].['+c.[TABLE_NAME]+'] where '+c.[COLUMN_NAME]+'=''G00000'' ;' AS query +FROM [INFORMATION_SCHEMA].[COLUMNS] c +WHERE [c].[TABLE_SCHEMA]='phar' +AND [c].[COLUMN_NAME] LIKE '%pharmacy_code' +; + diff --git a/DBG - craft cmds to move tempdb files.sql b/DBG - craft cmds to move tempdb files.sql new file mode 100644 index 0000000..5bcab15 --- /dev/null +++ b/DBG - craft cmds to move tempdb files.sql @@ -0,0 +1,17 @@ +DECLARE @newDriveAndFolder VARCHAR(8000); + +SET @newDriveAndFolder = 'F:\SQLDatabase'; + +SELECT [name] AS [Logical Name] + ,physical_name AS [Current Location] + ,state_desc AS [Status] + ,size / 128 AS [Size(MB)] --Number of 8KB pages / 128 = MB + ,'ALTER DATABASE tempdb MODIFY FILE (NAME = ' + QUOTENAME(f.[name]) + + CHAR(9) /* Tab */ + + ',FILENAME = ''' + @newDriveAndFolder + CHAR(92) /* Backslash */ + f.[name] + + CASE WHEN f.[type] = 1 /* Log */ THEN '.ldf' ELSE '.mdf' END + '''' + + ');' + AS [Create new TempDB files] +FROM sys.master_files f +WHERE f.database_id = DB_ID(N'tempdb') +ORDER BY f.[type]; \ No newline at end of file diff --git a/DBG - create xml for replication monitor.sql b/DBG - create xml for replication monitor.sql index 0d81b6d..df1f395 100644 --- a/DBG - create xml for replication monitor.sql +++ b/DBG - create xml for replication monitor.sql @@ -19,7 +19,7 @@ https://www.sqlservercentral.com/forums/topic/how-to-import-replication-monitor- and save it in the local folder - C:\Users\ua208700\AppData\Roaming\Microsoft\Microsoft SQL Server\150\Tools\SQL Monitor\rmsetting.xml + C:\Users\ua208700\AppData\Roaming\Microsoft\Microsoft SQL Server\160\Tools\SQL Monitor\rmsetting.xml */ USE [ControlCenter] @@ -30,7 +30,7 @@ DECLARE @tpl VARCHAR(MAX)=' @srv@\@inst@ 5 True - True + False False Snapshot Agent 0 @@ -43,7 +43,7 @@ DECLARE @tplDis VARCHAR(MAX)=' 5 True - True + False Snapshot Agent 0 -1 diff --git a/DBG - disable all jobs.sql b/DBG - disable all jobs.sql new file mode 100644 index 0000000..5a44bd0 --- /dev/null +++ b/DBG - disable all jobs.sql @@ -0,0 +1,2 @@ +select 'exec msdb.dbo.sp_update_job @job_name='''+name+''', @enabled = 0' +from msdb.dbo.sysjobs \ No newline at end of file diff --git a/DBG - disable all logins.sql b/DBG - disable all logins.sql new file mode 100644 index 0000000..17defa0 --- /dev/null +++ b/DBG - disable all logins.sql @@ -0,0 +1,7 @@ +SELECT 'ALTER LOGIN ['+name+'] DISABLE' FROM sys.syslogins WHERE isntgroup = 0 AND isntuser = 0 AND name NOT IN ('dba','sa') AND name NOT LIKE '#%' +UNION +SELECT 'ALTER LOGIN ['+name+'] DISABLE' FROM sys.syslogins WHERE isntuser = 1 AND name LIKE 'CENTRALINFRA%' +UNION +SELECT 'DENY CONNECT ANY DATABASE TO ['+name+']' FROM sys.syslogins WHERE isntgroup = 1 +UNION +SELECT 'DENY CONNECT SQL TO ['+name+']' FROM sys.syslogins WHERE isntgroup = 1 \ No newline at end of file diff --git a/DBG - extract db mail settings.sql b/DBG - extract db mail settings.sql new file mode 100644 index 0000000..1c986aa --- /dev/null +++ b/DBG - extract db mail settings.sql @@ -0,0 +1,121 @@ +USE msdb +GO + +Declare @TheResults varchar(max), + @vbCrLf CHAR(2) +SET @vbCrLf = CHAR(13) + CHAR(10) +SET @TheResults = ' +use master +go +sp_configure ''show advanced options'',1 +go +reconfigure with override +go +sp_configure ''Database Mail XPs'',1 +--go +--sp_configure ''SQL Mail XPs'',0 +go +reconfigure +go +' +SELECT @TheResults = @TheResults + ' +-------------------------------------------------------------------------------------------------- +-- BEGIN Mail Settings ' + p.name + ' +-------------------------------------------------------------------------------------------------- +IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_profile WHERE name = ''' + p.name + ''') + BEGIN + --CREATE Profile [' + p.name + '] + EXECUTE msdb.dbo.sysmail_add_profile_sp + @profile_name = ''' + p.name + ''', + @description = ''' + ISNULL(p.description,'') + '''; + END --IF EXISTS profile + ' + + + ' + IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_account WHERE name = ''' + a.name + ''') + BEGIN + --CREATE Account [' + a.name + '] + EXECUTE msdb.dbo.sysmail_add_account_sp + @account_name = ' + CASE WHEN a.name IS NULL THEN ' NULL ' ELSE + '''' + a.name + '''' END + ', + @email_address = ' + CASE WHEN a.email_address IS NULL THEN ' NULL ' ELSE + '''' + a.email_address + '''' END + ', + @display_name = ' + CASE WHEN a.display_name IS NULL THEN ' NULL ' ELSE + '''' + a.display_name + '''' END + ', + @replyto_address = ' + CASE WHEN a.replyto_address IS NULL THEN ' NULL ' ELSE + '''' + a.replyto_address + '''' END + ', + @description = ' + CASE WHEN a.description IS NULL THEN ' NULL ' ELSE + '''' + a.description + '''' END + ', + @mailserver_name = ' + CASE WHEN s.servername IS NULL THEN ' NULL ' ELSE + '''' + s.servername + '''' END + ', + @mailserver_type = ' + CASE WHEN s.servertype IS NULL THEN ' NULL ' ELSE + '''' + s.servertype + '''' END + ', + @port = ' + CASE WHEN s.port IS NULL THEN ' NULL ' ELSE + '''' + CONVERT(VARCHAR,s.port) + '''' END + ', + @username = ' + CASE WHEN c.credential_identity IS NULL THEN ' NULL ' ELSE + '''' + c.credential_identity + '''' END + ', + @password = ' + CASE WHEN c.credential_identity IS NULL THEN ' NULL ' ELSE + '''NotTheRealPassword''' END + ', + @use_default_credentials = ' + CASE WHEN s.use_default_credentials = 1 THEN ' 1 ' ELSE ' 0 ' END + ', + @enable_ssl = ' + CASE WHEN s.enable_ssl = 1 THEN ' 1 ' ELSE ' 0 ' END + '; + END --IF EXISTS account + ' + + ' +IF NOT EXISTS(SELECT * + FROM msdb.dbo.sysmail_profileaccount pa + INNER JOIN msdb.dbo.sysmail_profile p ON pa.profile_id = p.profile_id + INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id + WHERE p.name = ''' + p.name + ''' + AND a.name = ''' + a.name + ''') + BEGIN + -- Associate Account [' + a.name + '] to Profile [' + p.name + '] + EXECUTE msdb.dbo.sysmail_add_profileaccount_sp + @profile_name = ''' + p.name + ''', + @account_name = ''' + a.name + ''', + @sequence_number = ' + CONVERT(VARCHAR,pa.sequence_number) + ' ; + END +--IF EXISTS associate accounts to profiles +--------------------------------------------------------------------------------------------------- +-- Drop Settings For ' + p.name + ' +-------------------------------------------------------------------------------------------------- +/* +IF EXISTS(SELECT * + FROM msdb.dbo.sysmail_profileaccount pa + INNER JOIN msdb.dbo.sysmail_profile p ON pa.profile_id = p.profile_id + INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id + WHERE p.name = ''' + p.name + ''' + AND a.name = ''' + a.name + ''') + BEGIN + EXECUTE msdb.dbo.sysmail_delete_profileaccount_sp @profile_name = ''' + p.name + ''',@account_name = ''' + a.name + ''' + END +IF EXISTS(SELECT * FROM msdb.dbo.sysmail_account WHERE name = ''' + a.name + ''') + BEGIN + EXECUTE msdb.dbo.sysmail_delete_account_sp @account_name = ''' + a.name + ''' + END +IF EXISTS(SELECT * FROM msdb.dbo.sysmail_profile WHERE name = ''' + p.name + ''') + BEGIN + EXECUTE msdb.dbo.sysmail_delete_profile_sp @profile_name = ''' + p.name + ''' + END +*/ + ' +FROM msdb.dbo.sysmail_profile p +INNER JOIN msdb.dbo.sysmail_profileaccount pa ON p.profile_id = pa.profile_id +INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id +LEFT OUTER JOIN msdb.dbo.sysmail_server s ON a.account_id = s.account_id +LEFT OUTER JOIN sys.credentials c ON s.credential_id = c.credential_id + + ;WITH E01(N) AS (SELECT 1 UNION ALL SELECT 1 UNION ALL + SELECT 1 UNION ALL SELECT 1 UNION ALL + SELECT 1 UNION ALL SELECT 1 UNION ALL + SELECT 1 UNION ALL SELECT 1 UNION ALL + SELECT 1 UNION ALL SELECT 1), -- 10 or 10E01 rows + E02(N) AS (SELECT 1 FROM E01 a, E01 b), -- 100 or 10E02 rows + E04(N) AS (SELECT 1 FROM E02 a, E02 b), -- 10,000 or 10E04 rows + E08(N) AS (SELECT 1 FROM E04 a, E04 b), --100,000,000 or 10E08 rows + --E16(N) AS (SELECT 1 FROM E08 a, E08 b), --10E16 or more rows than you'll EVER need, + Tally(N) AS (SELECT ROW_NUMBER() OVER (ORDER BY N) FROM E08), + ItemSplit( + ItemOrder, + Item + ) as ( + SELECT N, + SUBSTRING(@vbCrLf + @TheResults + @vbCrLf,N + DATALENGTH(@vbCrLf),CHARINDEX(@vbCrLf,@vbCrLf + @TheResults + @vbCrLf,N + DATALENGTH(@vbCrLf)) - N - DATALENGTH(@vbCrLf)) + FROM Tally + WHERE N < DATALENGTH(@vbCrLf + @TheResults) + --WHERE N < DATALENGTH(@vbCrLf + @INPUT) -- REMOVED added @vbCrLf + AND SUBSTRING(@vbCrLf + @TheResults + @vbCrLf,N,DATALENGTH(@vbCrLf)) = @vbCrLf --Notice how we find the delimiter + ) + select + row_number() over (order by ItemOrder) as ItemID, + Item + from ItemSplit \ No newline at end of file diff --git a/DBG - syncro H debug.sql b/DBG - syncro H debug.sql new file mode 100644 index 0000000..d0904c5 --- /dev/null +++ b/DBG - syncro H debug.sql @@ -0,0 +1,158 @@ +/* 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. */ + + +/* +Step 1: identify the table id with the issue +Step 2: un-label rows from the table in step 1 + step 2.1: Check the values of the param @in_prc_code_excluded with the one in the steps of the job, theymight change in time + step 2.2: Check the value of @in_dest_subsidiary_id (AMA was 2 before Vesta, is 102 after Vesta) +Step 3: select all the logic between "(Step 3)" in the code to the end of the script and execute it +Step 4: replace the "NOT IN (table_id_with error)" to a "IN (table_id_with error)" and execute again the script from the "(step 3)" to the end +Step 5: if errors are showing, correct them and start again step 4, until success +Step 6: Profit ! +*/ +USE [Arizona] +GO + +--#region check how many AMR are impacted +/* 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 '2023-06-15' AND '2023-06-15 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 '2023-06-15' AND '2023-06-15 23:59:59' /* Flag comme extrait */ + --and AMR_APS_monitor_table = 460 /* Item_Key */ +--#endregion + + + + + +/* 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 '2023-06-15' AND '2023-06-15 23:59:59' /* Flag comme extrait */ + AND AMR_APS_monitor_table NOT IN (1817) /* Item_Key */ /* (334700 rows affected) */ + +/**************************/ +/* Etapes de la synchro H (Step 3)*/ + +/*--- 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 '2023-06-15' AND '2023-06-15 23:59:59' + AND amr.AMR_APS_monitor_table NOT IN (1817)) /* ID des AMR */ + +/* Step 5 */ +/* Passer une par une les differentes synchro de sub */ +/* SYNC - ITEM - H Synchronize items from 000 to CENT */ +exec aps_Sync_H_Item_Master + @in_source_subsidiary_id = 100, + @in_dest_subsidiary_id = 1, + @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 = 1 + +/* SYNC - ITEM - H Synchronize items from 000 to AMA */ +exec aps_Sync_H_Item_Master + @in_source_subsidiary_id = 100, + @in_dest_subsidiary_id = 102, + @in_dest_company_id = null, + @in_AMR_usage = 1, + @in_prc_code_excluded = ' ACTI;AUTO;CACT;CINT;CPUB;GPHA;GPUB;KUKO;LIMA;PACT;PDBR;PEXF;PMED;PPHA;PPUB;PREF;PRIC;RBP2;RBP3;RBP4;VERT;XEXF;XPUB;', + @in_crt_code_excluded = 'PLC', + @in_spid = @@spid, + @in_extraction_timestamp = @extraction_timestamp + +/* SYNC - ITEM - H Synchronize items from 000 to COOP */ +exec aps_Sync_H_Item_Master + @in_source_subsidiary_id = 100, + @in_dest_subsidiary_id = 124, + @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 = 9 + +/*-- 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 + diff --git a/EXPLOIT - Commvault restore via CLR.sql b/EXPLOIT - Commvault restore via CLR.sql new file mode 100644 index 0000000..35c2d0e --- /dev/null +++ b/EXPLOIT - Commvault restore via CLR.sql @@ -0,0 +1,24 @@ +USE [HCITools]; +DECLARE @password VARCHAR(255); +SET @password + = dbo.fn_Decrypt( + 0x01000000C2811DD6D0339FF2EFE6AE1181B3469D18798020836E3E0A1E4BC96D548B4FCDFFB77F264E1A4F42AD91F785284A6F5D4F3E533B0355E88F91A61E7E671472D3F580FC36CCF0AE48858099190C1B7E3A1A2A292A3E8809B40EAB6EAECF3C0FF6871CAF54A3928615C21830602BCB12F1F973E4B4B1F34A613B342C397372596025DB62CB426319AE916D0DC5CCAED8A62675D7602D592A92); + +DECLARE @t DATETIME = CURRENT_TIMESTAMP; + +/* RESTORE WITH MOVE */ +EXEC [dba].[Commvault_Operation] @in_type = 'Restore', + @in_username = 'CLI_SQL_Backup', + @in_password = @password, + @in_toTimeValue = @t, + @in_restoreSource = 'olpPRIX_Galenicare', + @in_newDatabaseName = 'olpPRIX_Galenicare', + @in_destinationInstance_clientName = 'swopxqms01.centralinfra.net\TGALOLPP01', + @in_destinationInstance_instanceName = 'swopxqms01.centralinfra.net\TGALOLPP01', + @in_targetMDFPath = 'd:\sqlDatabase', + @in_targetLDFPath = 'd:\sqlDatabase', + --@in_targetFileStreamPath = 'f:\sqlDatabase', + @in_callerApp = 'TSC' +; +GO + diff --git a/EXPLOIT - list databases sizes.sql b/EXPLOIT - list databases sizes.sql index 8347dcf..9e1739a 100644 --- a/EXPLOIT - list databases sizes.sql +++ b/EXPLOIT - list databases sizes.sql @@ -38,8 +38,9 @@ FROM sys.master_files F JOIN [#dbs] [d2] ON d2.[database_name] = d.[name] WHERE f.type_desc IN ( 'ROWS' --mdf - --'LOG' + --,'LOG' ) +--AND f.[physical_name] LIKE 'f%' --AND d.[is_read_only] = 0 --AND d.[is_auto_shrink_on] = 0 --AND d.name NOT IN ( @@ -51,47 +52,21 @@ WHERE f.type_desc IN ( ORDER BY [d2].[row_size_mb] DESC, d.name DESC, f.name ASC ; --free disk space -select distinct -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(((convert(float, b.available_bytes) / convert(float, b.total_bytes)) * 100),1)) as [percent_free] -, convert(bigint, round(((b.available_bytes / 1024.0)/1024.0),0)) as [free_mb] -, convert(bigint, round(((b.total_bytes / 1024.0)/1024.0),0)) as [total_mb] -, convert(bigint, round((((b.total_bytes - b.available_bytes) / 1024.0)/1024.0),0)) as [used_mb] -, CURRENT_TIMESTAMP AS now -,REPLACE(@@SERVERNAME ,'\apssql','')AS srvName -from sys.master_files as [a] -CROSS APPLY sys.dm_os_volume_stats(a.database_id, a.[file_id]) as [b] -ORDER BY [percent_free] ASC - -RETURN - -SELECT * -FROM sys.master_files F WITH(NOWAIT) -WHERE f.[physical_name] LIKE 'f:%' - - - -/* ---craft data files shrink without reorganizing -SELECT - d.[name] - ,f.[physical_name] - ,f.[name] - ,'USE '+d.name+'; -DBCC SHRINKFILE (N'''+f.[name]+''' , 0, TRUNCATEONLY); -GO - -' AS shrinkData -FROM sys.master_files F - JOIN sys.databases d ON d.[database_id] = f.[database_id] -WHERE f.type_desc = 'ROWS' --mdf -AND d.[is_read_only] = 0 -AND d.[is_auto_shrink_on] = 0 -AND d.name NOT IN ( - 'master' - ,'tempdb' - ,'model' - ,'msdb' -) -*/ \ No newline at end of file +SELECT DISTINCT + 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(((CONVERT(FLOAT, [b].[available_bytes]) / CONVERT(FLOAT, [b].[total_bytes])) * 100), 1)) AS [percent_free], + CONVERT(BIGINT, ROUND((([b].[available_bytes] / 1024.0) / 1024.0 / 1024.0), 0)) AS [free_gb], + CONVERT(BIGINT, ROUND((([b].[available_bytes] / 1024.0) / 1024.0 ), 0)) AS [free_mb], + CONVERT(BIGINT, ROUND((([b].[total_bytes] / 1024.0) / 1024.0 / 1024.0), 0)) AS [total_gb], + CONVERT(BIGINT, ROUND(((([b].[total_bytes] - [b].[available_bytes]) / 1024.0) / 1024.0 / 1024.0), 0)) AS [used_gb], + CONVERT(BIGINT, ROUND((([b].[total_bytes] / 1024.0) / 1024.0), 0)) / 100 * 5 / 1024.0 AS [5% space in Go is], + CONVERT(BIGINT, ROUND((([b].[total_bytes] / 1024.0) / 1024.0), 0)) / 100 * 10 / 1024.0 AS [10% space in Go is], + CONVERT(BIGINT, ROUND((([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 sys.dm_os_volume_stats(a.database_id, a.[file_id]) AS [b] + ORDER BY [percent_free] ASC; diff --git a/MIG - compare settings between 2 instances via linked server.sql b/MIG - compare settings between 2 instances via linked server.sql new file mode 100644 index 0000000..9c10fd8 --- /dev/null +++ b/MIG - compare settings between 2 instances via linked server.sql @@ -0,0 +1,41 @@ +IF OBJECT_ID('tempdb..#new')IS NOT NULL BEGIN; + DROP TABLE #new; +END; + +SELECT * +INTO #new +from master.sys.configurations + +--except +IF OBJECT_ID('tempdb..#old')IS NOT NULL BEGIN; + DROP TABLE #old; +END; + +select * +INTO #old +from sunaps.master.sys.configurations + +SELECT [y].[name], + [y].[new_val], + [y].[old_val], + [y].[src] +FROM ( + SELECT [x].[name], + [x].[new_val], + [x].[old_val], + [x].[src], + ROW_NUMBER()OVER(PARTITION BY [x].[name] ORDER BY [x].[src]) AS rnk + FROM ( + SELECT n.name, n.value AS new_val, o.[value] AS old_val, 'new' AS src + FROM [#new] n + LEFT JOIN [#old] o ON o.[name] = n.[name] + WHERE ISNULL(n.[value],'new') <> ISNULL(o.[value], 'old') + UNION + SELECT n.name, n.value AS new_val, o.[value] AS old_val, 'old' + FROM [#old] o + LEFT JOIN [#new] n ON o.[name] = n.[name] + WHERE ISNULL(n.[value],'new') <> ISNULL(o.[value], 'old') + )x +)y +WHERE [y].[rnk] = 1 +ORDER BY [y].[name] \ No newline at end of file diff --git a/OCTPDBA-494 - Triafin SSRS report performances/.vs/OCTPDBA-494 - Triafin SSRS report performances/v15/.ssms_suo b/OCTPDBA-494 - Triafin SSRS report performances/.vs/OCTPDBA-494 - Triafin SSRS report performances/v15/.ssms_suo index 59ba876..fc472b8 100644 Binary files a/OCTPDBA-494 - Triafin SSRS report performances/.vs/OCTPDBA-494 - Triafin SSRS report performances/v15/.ssms_suo and b/OCTPDBA-494 - Triafin SSRS report performances/.vs/OCTPDBA-494 - Triafin SSRS report performances/v15/.ssms_suo differ diff --git a/OCTPDBA-565 manage index 23.2/.vs/OCTPDBA-565 manage index 23.2/v15/.ssms_suo b/OCTPDBA-565 manage index 23.2/.vs/OCTPDBA-565 manage index 23.2/v15/.ssms_suo index 555b04a..1e18b3f 100644 Binary files a/OCTPDBA-565 manage index 23.2/.vs/OCTPDBA-565 manage index 23.2/v15/.ssms_suo and b/OCTPDBA-565 manage index 23.2/.vs/OCTPDBA-565 manage index 23.2/v15/.ssms_suo differ diff --git a/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/SQLQuery1.sql b/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/SQLQuery1.sql new file mode 100644 index 0000000..e69de29 diff --git a/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/centrale.sql b/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/centrale.sql index 6df5700..55d74f8 100644 --- a/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/centrale.sql +++ b/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/centrale.sql @@ -83,14 +83,14 @@ BEGIN PRINT 'create NCIX_Fixed_price_COL_FP_tariff_type' END - IF NOT EXISTS( + IF EXISTS( SELECT [x].[index_id] FROM [Arizona].[sys].[indexes] x WHERE [x].[name] = 'NCIX_Fixed_price_COL_FP_tariff_type_FP_start_date' AND [x].[object_id] = OBJECT_ID('arizona.dbo.Fixed_price') )BEGIN - CREATE INDEX [NCIX_Fixed_price_COL_FP_tariff_type_FP_start_date] ON [Arizona].[dbo].[Fixed_price] ([FP_tariff_type],[FP_start_date]) INCLUDE ([Fixed_price_ID], [FP_item], [FP_price_code], [FP_end_date], [FP_tax_incl_price_per_unit], [FP_quantity]); - PRINT 'create xxx' + EXEC('use arizona; DROP INDEX [dbo].[Fixed_price].[NCIX_Fixed_price_COL_FP_tariff_type_FP_start_date];') + PRINT 'drop NCIX_Fixed_price_COL_FP_tariff_type_FP_start_date' END IF NOT EXISTS( @@ -158,6 +158,17 @@ BEGIN PRINT 'create NCIX_Item_status_history_COL_ITSH_value_date' END + /* aps_monitor_row */ + IF NOT EXISTS( + SELECT [x].[index_id] + FROM [Arizona].[sys].[indexes] x + WHERE [x].[name] = 'NCIX_APS_monitor_row_COL_AMR_APS_monitor_table' + AND [x].[object_id] = OBJECT_ID('arizona.dbo.APS_monitor_row') + )BEGIN + CREATE INDEX [NCIX_APS_monitor_row_COL_AMR_APS_monitor_table] ON [Arizona].[dbo].[APS_monitor_row] ([AMR_APS_monitor_table], [AMR_horizontal_extraction_TS],[AMR_type_of_change]) INCLUDE ([AMR_row_GUID]); + PRINT 'Create NCIX_APS_monitor_row_COL_AMR_APS_monitor_table' + END + /* ------------------------------------------------------ */ IF NOT EXISTS( SELECT [x].[index_id] diff --git a/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/desc.txt b/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/desc.txt deleted file mode 100644 index 8cb3dee..0000000 --- a/OCTPDBA-565 manage index 23.2/OCTPDBA-565 manage index 23.2/desc.txt +++ /dev/null @@ -1,232 +0,0 @@ -/* - -octpdba-497 () have removed openrowset to amavitaLiveAPS, everything is centralised now. -Each procs that have been altered exists with a copy with the suffix "octpdba-497" (typo in some, where the suffix is ctpdba-497). -The copy with the suffix holds the old code. - - -usage of openrowset on suncent - Object name Schema Database Type - ABD_Cent_Load dbo ArizonaCUST Procedures - ABD_Cent_Load_CTPDBA-497 dbo ArizonaCUST Procedures - ACC_Cent_Load dbo ArizonaCUST Procedures - ACC_Cent_Load_CTPDBA-497 dbo ArizonaCUST Procedures - AP_Cent_Load dbo ArizonaCUST Procedures - AP_Cent_Load_OCTPDBA-497 dbo ArizonaCUST Procedures - APR_Cent_Load dbo ArizonaCUST Procedures - aps_Central_Annual_Inventory_Load dbo ArizonaCUST Procedures - aps_GAL_olpFACT_controle_PHA dbo ArizonaCUST Procedures - aps_SUN_Cession_Creances dbo ArizonaCUST Procedures - aps_SUN_Get_Balanced_Scorecard_Data_From_Central dbo ArizonaCUST Procedures - AS_Cent_Load dbo ArizonaCUST Procedures - AS_Cent_Load__OCTPDBA-497 dbo ArizonaCUST Procedures - AT_Cent_Aggregated_Data_Load dbo ArizonaCUST Procedures - AT_Cent_Aggregated_Data_Load_OCTPDBA-497 dbo ArizonaCUST Procedures - AT_Cent_Extract_specific_pd_codes dbo ArizonaCUST Procedures - AT_Cent_Load dbo ArizonaCUST Procedures - CRMCRD_Cent_Load dbo ArizonaCUST Procedures - CRMCRD_Cent_Load_OCTPDBA-497 dbo ArizonaCUST Procedures - CRSH_Cent_Load dbo ArizonaCUST Procedures - CRSO_Cent_Load dbo ArizonaCUST Procedures - CRSO_Cent_Load_OCTPDBA-497 dbo ArizonaCUST Procedures - DHICI_Cent_Load dbo ArizonaCUST Procedures - DHICI_Cent_Load_OCTPDBA-497 dbo ArizonaCUST Procedures - FM_Cent_Load dbo ArizonaCUST Procedures - ITSC_Cent_Load dbo ArizonaCUST Procedures - SSRS_CR_Sales_Select_For_CR_Operation dbo ArizonaCUST Procedures - SSRS_Galenicare_Invoice_Payment_List dbo ArizonaCUST Procedures - -stuff that stinks: - ABD_Cent_Load - user sqlSyncAccountingExtractionUsr with it's password in the proc - - ACC_Cent_Load - seems that SA passwords are in there. - not the actual SA passwords, might be old code that was not adapted - - AP_Cent_Load - user sqlSyncAccountingExtractionUsr with it's password in the proc - - AT_Cent_Load - Still have a link to AMAVITALIVEAPS - - - -reports: - FidelityCardSales - Rapport KO. Son lancement remonte le message suivant - An error has occurred during report processing. (rsProcessingAborted) - Query execution failed for dataset 'DSMain'. (rsErrorExecutingCommand) - Could not find stored procedure 'Extraction_Galenicare_Sales_Fidelity_Card'. - - Lors de la sélection de la "company", lance une query sur Gaia qui retourne toutes les OU de tous les formats ainsi que les "cost centers" - --------------------------- - with Pharmacy ([Company], [Code], [Code_name]) as - ( - select coalesce(asub.Code, OU_subsidiary_prefix) - , OU_code - , OU_code + ' ' + OU_short_name - from [crs].[vwOrganizationalUnit] ou with (nolock) - inner join phar.address_criteria adcr with (nolock) - on ou.OU_pharmacy_code = adcr.ADCR_pharmacy_code - and ou.OU_address = adcr.ADCR_address - inner join phar.criteria cr with (nolock) - on adcr.ADCR_criteria = cr.Criteria_ID - and adcr.ADCR_pharmacy_code = cr.CR_pharmacy_code - inner join [phar].[Criteria_type] crt with (nolock) - on cr.CR_criteria_type = crt.Criteria_type_ID - and cr.CR_pharmacy_code = crt.CRT_pharmacy_code - left join crs.AdditionalSubsidiaryLink asl with (nolock) - on ou.Reference_Organizational_unit_ID = asl.OrganizationalUnitId - left join crs.AdditionalSubsidiary asub with (nolock) - on asl.AdditionalSubsidiaryId = asub.AdditionalSubsidiaryId - where crt.CRT_type = 1 and crt.crt_code = 'ENV' - and ou.OU_subsidiary_prefix is not null - ) - select 1 as Position, [Company], null as [Code], '' as [Code_name] - from [Pharmacy] - union - select 2 as Position, [Company], [Code], [Code_name] - from Pharmacy - order by Position, Company, Code - - - with CostCenter([Code], [Company]) - as - (SELECT pcck.PCCK_key AS [Code], - coalesce(asub.Code, ou.OU_subsidiary_prefix) AS [Company] - from crs.vwOrganizationalUnit ou with (nolock) - left join crs.AdditionalSubsidiaryLink asl with (nolock) - on ou.Reference_Organizational_unit_ID = asl.OrganizationalUnitId - left join crs.AdditionalSubsidiary asub with (nolock) - on asl.AdditionalSubsidiaryId = asub.AdditionalSubsidiaryId - inner join phar.Profit_cost_center_key pcck with (nolock) - on pcck.PCCK_profit_cost_center = ou.OU_profit_cost_center - and pcck.PCCK_pharmacy_code = ou.OU_pharmacy_code - inner join phar.Fiscal_year fy with (nolock) - on fy.Fiscal_year_ID = pcck.PCCK_fiscal_year - and fy.FY_pharmacy_code = pcck.PCCK_pharmacy_code - and fy.FY_subsidiary = ou.OU_subsidiary - and fy.FY_number = 2022 - and pcck.PCCK_type = Case When coalesce(asub.Code, ou.OU_subsidiary_prefix) in ('CVI', 'SUN') Then 3 - Else 1 End - where ou.OU_centrale_code = 'G') - SELECT 1 as Position, null as [Code], '' as [Code_name], null as [Company] from CostCenter - union - SELECT 2 as Position, null as [Code], '' as [Code_name], [Company] from CostCenter - union - SELECT 3 as Position, [Code], [Code] as [Code_name], [Company] from CostCenter - order by Position, Company, Code - --------------------------- - - LifeStageInvoices - l'ouverture rdu rapport lance 2 query. la 1ere liste les "cost centeers" comme dans le rapport précédent - Démarre la query suivante en environ 38 secondes: - ---------------- - exec sp_executesql N'SELECT dh.DH_doc_number AS InvoiceNumber, - dh.DH_value_date AS InvoiceDate, - et.ET_debit_base_amount AS InvoiceAmount, - dh.DH_sold_to_text AS CustomerName, - coalesce(et.ET_debit_base_amount, 0) - coalesce(SUM(etr.ETR_base_amount), 0) AS DueAmount, - dh.DH_invoice_group AS LifeStageNumber, - ins.PHIN_name_german AS [Debtor] - FROM [Gaia].[phar].[Document_header] dh WITH (nolock) - INNER JOIN phar.Entry et WITH (nolock) - ON dh.document_header_id = et.ET_document_header - AND dh.dh_account = et.Et_account - AND dh.DH_pharmacy_code = et.ET_pharmacy_code - LEFT JOIN phar.Entry_reconciliation etr WITH (nolock) - ON et.Entry_ID = etr.ETR_entry - AND et.ET_pharmacy_code = etr.ETR_pharmacy_code - left join phar.PH_insurance as ins with (nolock) - on ins.PHIN_address = dh.DH_send_bill_to - and left(ins.PHIN_pharmacy_code, 1) = left(dh.DH_pharmacy_code, 1) - WHERE dh.DH_invoice_group IS NOT NULL - AND dh.DH_our_ref LIKE ''LifeStage%'' - AND dh.DH_pharmacy_code = @PharmacyLifeStage - GROUP BY dh.DH_doc_number, - dh.Document_header_ID, - dh.DH_value_date, - et.ET_debit_base_amount, - dh.DH_sold_to_text, - dh.DH_BVR_reference, - dh.DH_account, - dh.DH_invoice_group, - dh.DH_our_ref, - et.ET_reconciliation_status, - ins.PHIN_name_german - HAVING ((@LifeStageInvoiceNumber is not null AND dh.DH_invoice_group like @LifeStageInvoiceNumber + ''%'') - OR (@TriaPharmInvoiceNumber is not null AND @LifeStageInvoiceNumber is null AND dh.DH_Doc_number like @TriaPharmInvoiceNumber + ''%'') - OR (@LifeStageInvoiceNumber is null AND @TriaPharmInvoiceNumber is null AND dh.DH_value_date between @InvoiceDateFrom AND isnull(@InvoiceDateTo, cast(getDate() as date)) - AND (@OpenedInvoice = 0 OR isnull(et.ET_reconciliation_status, 1) = 1)));',N'@InvoiceDateFrom datetime,@InvoiceDateTo nvarchar(4000),@LifeStageInvoiceNumber nvarchar(4000),@OpenedInvoice bit,@TriaPharmInvoiceNumber nvarchar(4000),@PharmacyLifeStage nvarchar(6)',@InvoiceDateFrom='2022-01-01 00:00:00',@InvoiceDateTo=NULL,@LifeStageInvoiceNumber=NULL,@OpenedInvoice=1,@TriaPharmInvoiceNumber=NULL,@PharmacyLifeStage=N'GAM316' - ---------------- - - OpenInvoiceDetails: - nécessite un "master id", l'entrée de data bidon remonte la query suivante lancée: - ------------------- - (@InvoiceDateFrom datetime,@InvoiceDateTo nvarchar(4000),@LifeStageInvoiceNumber nvarchar(4000),@OpenedInvoice bit,@TriaPharmInvoiceNumber nvarchar(4000),@PharmacyLifeStage nvarchar(6))SELECT dh.DH_doc_number AS InvoiceNumber, - dh.DH_value_date AS InvoiceDate, - et.ET_debit_base_amount AS InvoiceAmount, - dh.DH_sold_to_text AS CustomerName, - coalesce(et.ET_debit_base_amount, 0) - coalesce(SUM(etr.ETR_base_amount), 0) AS DueAmount, - dh.DH_invoice_group AS LifeStageNumber, - ins.PHIN_name_german AS [Debtor] - FROM [Gaia].[phar].[Document_header] dh WITH (nolock) - INNER JOIN phar.Entry et WITH (nolock) - ON dh.document_header_id = et.ET_document_header - AND dh.dh_account = et.Et_account - AND dh.DH_pharmacy_code = et.ET_pharmacy_code - LEFT JOIN phar.Entry_reconciliation etr WITH (nolock) - ON et.Entry_ID = etr.ETR_entry - AND et.ET_pharmacy_code = etr.ETR_pharmacy_code - left join phar.PH_insurance as ins with (nolock) - on ins.PHIN_address = dh.DH_send_bill_to - and left(ins.PHIN_pharmacy_code, 1) = left(dh.DH_pharmacy_code, 1) - WHERE dh.DH_invoice_group IS NOT NULL - AND dh.DH_our_ref LIKE 'LifeStage%' - AND dh.DH_pharmacy_code = @PharmacyLifeStage - GROUP BY dh.DH_doc_number, - dh.Document_header_ID, - dh.DH_value_date, - et.ET_debit_base_amount, - dh.DH_sold_to_text, - dh.DH_BVR_reference, - dh.DH_account, - dh.DH_invoice_group, - dh.DH_our_ref, - et.ET_reconciliation_status, - ins.PHIN_name_german - HAVING ((@LifeStageInvoiceNumber is not null AND dh.DH_invoice_group like @LifeStageInvoiceNumber + '%') - OR (@TriaPharmInvoiceNumber is not null AND @LifeStageInvoiceNumber is null AND dh.DH_Doc_number like @TriaPharmInvoiceNumber + '%') - OR (@LifeStageInvoiceNumber is null AND @TriaPharmInvoiceNumber is null AND dh.DH_value_date between @InvoiceDateFrom AND isnull(@InvoiceDateTo, cast(getDate() as date)) - AND (@OpenedInvoice = 0 OR isnull(et.ET_reconciliation_status, 1) = 1))); - ------------------- - - OpenInvoice: - lance une query en entrant sur le rapport pour lister les formats et les OU. - ----------------- - select ou.Organizational_unit_ID [Reference_Organizational_unit_ID], - case when charindex(ou.OU_code,ou.OU_short_name) > 0 then ou.OU_short_name else ou.OU_short_name + ' ' + ou.OU_code end [Name] - from phar.Organizational_unit as ou - join [crs].[vwSubsidiary] as sub - on sub.Reference_Subsidiary_ID = ou.OU_subsidiary - join phar.PH_organizational_unit as phou - on phou.PHOU_organizational_unit = ou.Organizational_unit_ID - and phou.PHOU_pharmacy_code = ou.OU_pharmacy_code - left join phar.Organizational_unit ou2 - on ou2.OU_master_ID = ou.Organizational_unit_ID and ou2.OU_pharmacy_code = 'A00000' - where ou.OU_pharmacy_code = 'G00000' - and ou.OU_subsidiary = 1 - order by ou.OU_subsidiary, ou.OU_short_name - - select sub.Reference_Subsidiary_ID, - sub.SUB_prefix - from crs.vwSubsidiary sub with (nolock) - ----------------- - - Le lancement du report lance la proc reportOpenInvoice qui mouline bien sur Gaia - ----------------- - exec crs.ReportOpenInvoices @Format=N'1',@Pharmacy=N'185;157;249;339;366;205;142;308;186;354;285;296;148;298;341;284;322;290;169;144;349;173;163;133;348;342;146;261;124;174;248;137;260;202;117;156;194;254;207;287;334;247;227;153;552;345;663;306;128;130;129;327;131;844;843;300;189;295;338;333;217;110;161;198;329;111;109;270;210;330;103;343;854;224;340;336;272;145;328;166;346;136;859;122;134;135;125;314;118;307;123;760;292;164;120;301;291;195;282;721;571;132;317;114;113;112;115;119;305;302;570;319;544;140;323;373;320;138;139;303;344;318;147;274;310;358;357;359;574;575;873;321;311;175;360;388;331;216;560;143;126;559;299;121;781;335;304',@InvoiceNumber=NULL,@NegativeAmount=0 - ----------------- - -*/ \ No newline at end of file diff --git a/OCTPDBA-662 - Export LORE in CSV format for AI/extract.ps1 b/OCTPDBA-662 - Export LORE in CSV format for AI/extract.ps1 new file mode 100644 index 0000000..6ee30af --- /dev/null +++ b/OCTPDBA-662 - Export LORE in CSV format for AI/extract.ps1 @@ -0,0 +1,107 @@ +<# +OCTPDBA-662 + +This script will be used to run a query on every pharmacies and store the output in a CSV file +There will be 1 file per pharmacy generated by the script. +The CSV are overwritten on each execution of the script. +Each execution of the script starts from the 1st array $target entry. + +If $create_concatenated is true, a file containing all the pharmacies will be create d at the end of the script. +#> + +<# +to fetch the list of pharmacies to run the query against, run this query on HCIMON and copy the result to $target + +USE [ControlCenter] +DECLARE @res VARCHAR(MAX)='' + +SELECT @res = @res + ',"'+[s].[SE_DNS]+'"' +FROM [dbo].[Server] s + JOIN [dbo].[Entity] e ON [e].[EN_id] = [s].[SE_entity] +WHERE e.[EN_id] IN ( +1, --sun +2, --ama +21 --cvi +) +AND [s].[SE_DNS] NOT LIKE '%REF____.%' +AND ( + s.[SE_end_prod_date] IS NULL + OR s.[SE_end_prod_date] > CURRENT_TIMESTAMP +) +ORDER BY s.[SE_entity], [s].[SE_OU_code]; + +SELECT STUFF(@res,1,1,'') as OU_list + +#> + +#$target="sun001aps.sunstore.ch","sun002aps.sunstore.ch","sun003aps.sunstore.ch","sun011aps.sunstore.ch","sun099aps.sunstore.ch","sun100aps.sunstore.ch","sun102aps.sunstore.ch","sun103aps.sunstore.ch","sun111aps.sunstore.ch","sun115aps.sunstore.ch","sun121aps.sunstore.ch","sun131aps.sunstore.ch","sun135aps.sunstore.ch","sun141aps.sunstore.ch","sun143aps.sunstore.ch","sun151aps.sunstore.ch","sun161aps.sunstore.ch","sun171aps.sunstore.ch","sun181aps.sunstore.ch","sun185aps.sunstore.ch","sun186aps.sunstore.ch","sun191aps.sunstore.ch","sun201aps.sunstore.ch","sun211aps.sunstore.ch","sun221aps.sunstore.ch","sun231aps.sunstore.ch","sun241aps.sunstore.ch","sun245aps.sunstore.ch","sun251aps.sunstore.ch","sun261aps.sunstore.ch","sun267aps.sunstore.ch","sun291aps.sunstore.ch","sun301aps.sunstore.ch","sun311aps.sunstore.ch","sun321aps.sunstore.ch","sun331aps.sunstore.ch","sun341aps.sunstore.ch","sun351aps.sunstore.ch","sun361aps.sunstore.ch","sun371aps.sunstore.ch","sun381aps.sunstore.ch","sun391aps.sunstore.ch","sun401aps.sunstore.ch","sun421aps.sunstore.ch","sun431aps.sunstore.ch","sun441aps.sunstore.ch","sun451aps.sunstore.ch","sun461aps.sunstore.ch","sun471aps.sunstore.ch","sun481aps.sunstore.ch","sun491aps.sunstore.ch","sun501aps.sunstore.ch","sun511aps.sunstore.ch","sun521aps.sunstore.ch","sun531aps.sunstore.ch","sun541aps.sunstore.ch","sun550aps.sunstore.ch","sun551aps.sunstore.ch","sun571aps.sunstore.ch","sun591aps.sunstore.ch","sun601aps.sunstore.ch","sun621aps.sunstore.ch","sun645aps.sunstore.ch","sun651aps.sunstore.ch","sun661aps.sunstore.ch","sun671aps.sunstore.ch","sun691aps.sunstore.ch","sun721aps.sunstore.ch","sun731aps.sunstore.ch","sun741aps.sunstore.ch","sun751aps.sunstore.ch","sun761aps.sunstore.ch","sun771aps.sunstore.ch","sun781aps.sunstore.ch","sun791aps.sunstore.ch","sun797aps.sunstore.ch","sun811aps.sunstore.ch","sun841aps.sunstore.ch","sun851aps.sunstore.ch","sun871aps.sunstore.ch","sun891aps.sunstore.ch","sun892aps.sunstore.ch","sun893aps.sunstore.ch","sun894aps.sunstore.ch","sun895aps.sunstore.ch","sun896aps.sunstore.ch","sun919aps.sunstore.ch","sun950aps.sunstore.ch","sun952aps.sunstore.ch","sun953aps.sunstore.ch","ama001aps.amavita.ch","ama002aps.amavita.ch","ama003aps.amavita.ch","ama004aps.amavita.ch","ama006aps.amavita.ch","ama007aps.amavita.ch","ama008aps.amavita.ch","ama009aps.amavita.ch","ama011aps.amavita.ch","ama012aps.amavita.ch","ama013aps.amavita.ch","ama017aps.amavita.ch","ama018aps.amavita.ch","ama019aps.amavita.ch","ama021aps.amavita.ch","ama022aps.amavita.ch","ama023aps.amavita.ch","ama027aps.amavita.ch","ama028aps.amavita.ch","ama029aps.amavita.ch","ama030aps.amavita.ch","ama031aps.amavita.ch","ama032aps.amavita.ch","ama033aps.amavita.ch","ama034aps.amavita.ch","ama035aps.amavita.ch","ama036aps.amavita.ch","ama038aps.amavita.ch","ama039aps.amavita.ch","ama040aps.amavita.ch","ama041aps.amavita.ch","ama043aps.amavita.ch","ama044aps.amavita.ch","ama045aps.amavita.ch","ama046aps.amavita.ch","ama047aps.amavita.ch","ama048aps.amavita.ch","ama049aps.amavita.ch","ama050aps.amavita.ch","ama051aps.amavita.ch","ama052aps.amavita.ch","ama053aps.amavita.ch","ama055aps.amavita.ch","ama056aps.amavita.ch","ama058aps.amavita.ch","ama060aps.amavita.ch","ama062aps.amavita.ch","ama064aps.amavita.ch","ama065aps.amavita.ch","ama066aps.amavita.ch","ama067aps.amavita.ch","ama076aps.amavita.ch","ama079aps.amavita.ch","ama080aps.amavita.ch","ama081aps.amavita.ch","ama082aps.amavita.ch","ama083aps.amavita.ch","ama084aps.amavita.ch","ama085aps.amavita.ch","ama086aps.amavita.ch","ama087aps.amavita.ch","ama089aps.amavita.ch","ama090aps.amavita.ch","ama091aps.amavita.ch","ama093aps.amavita.ch","ama095aps.amavita.ch","ama096aps.amavita.ch","ama097aps.amavita.ch","ama201aps.amavita.ch","ama203aps.amavita.ch","ama204aps.amavita.ch","ama206aps.amavita.ch","ama207aps.amavita.ch","ama208aps.amavita.ch","ama209aps.amavita.ch","ama212aps.amavita.ch","ama214aps.amavita.ch","ama215aps.amavita.ch","ama216aps.amavita.ch","ama217aps.amavita.ch","ama219aps.amavita.ch","ama220aps.amavita.ch","ama221aps.amavita.ch","ama222aps.amavita.ch","ama223aps.amavita.ch","ama224aps.amavita.ch","ama225aps.amavita.ch","ama226aps.amavita.ch","ama227aps.amavita.ch","ama228aps.amavita.ch","ama230aps.amavita.ch","ama232aps.amavita.ch","ama233aps.amavita.ch","ama235aps.amavita.ch","ama236aps.amavita.ch","ama237aps.amavita.ch","ama238aps.amavita.ch","ama239aps.amavita.ch","ama240aps.amavita.ch","ama241aps.amavita.ch","ama242aps.amavita.ch","ama243aps.amavita.ch","ama244aps.amavita.ch","ama246aps.amavita.ch","ama247aps.amavita.ch","ama248aps.amavita.ch","ama249aps.amavita.ch","ama250aps.amavita.ch","ama251aps.amavita.ch","ama253aps.amavita.ch","ama254aps.amavita.ch","ama255aps.amavita.ch","ama256aps.amavita.ch","ama257aps.amavita.ch","ama259aps.amavita.ch","ama260aps.amavita.ch","ama262aps.amavita.ch","ama263aps.amavita.ch","ama264aps.amavita.ch","ama265aps.amavita.ch","ama266aps.amavita.ch","ama267aps.amavita.ch","ama269aps.amavita.ch","ama270aps.amavita.ch","ama271aps.amavita.ch","ama272aps.amavita.ch","ama273aps.amavita.ch","ama274aps.amavita.ch","ama276aps.amavita.ch","ama278aps.amavita.ch","ama279aps.amavita.ch","ama280aps.amavita.ch","ama282aps.amavita.ch","ama283aps.amavita.ch","ama287aps.amavita.ch","ama289aps.amavita.ch","ama292aps.amavita.ch","ama293aps.amavita.ch","ama294aps.amavita.ch","ama295aps.amavita.ch","ama296aps.amavita.ch","ama299aps.amavita.ch","ama300aps.amavita.ch","ama301aps.amavita.ch","ama302aps.amavita.ch","ama303aps.amavita.ch","ama304aps.amavita.ch","ama305aps.amavita.ch","ama306aps.amavita.ch","ama308aps.amavita.ch","ama311aps.amavita.ch","ama312aps.amavita.ch","ama315aps.amavita.ch","ama316aps.amavita.ch","ama319aps.amavita.ch","ama321aps.amavita.ch","ama322aps.amavita.ch","ama323aps.amavita.ch","ama324aps.amavita.ch","ama325aps.amavita.ch","ama331aps.amavita.ch","ama332aps.amavita.ch","ama333aps.amavita.ch","ama334aps.amavita.ch","ama335aps.amavita.ch","ama336aps.amavita.ch","ama337aps.amavita.ch","ama339aps.amavita.ch","ama341aps.amavita.ch","ama349aps.amavita.ch","ama449aps.amavita.ch","ama550aps.amavita.ch","ama551aps.amavita.ch","ama552aps.amavita.ch","ama553aps.amavita.ch","ama557aps.amavita.ch","ama558aps.amavita.ch","ama560aps.amavita.ch","ama561aps.amavita.ch","ama562aps.amavita.ch","ama563aps.amavita.ch","ama564aps.amavita.ch","ama601aps.amavita.ch","ama602aps.amavita.ch","ama603aps.amavita.ch","ama604aps.amavita.ch","ama605aps.amavita.ch","ama609aps.amavita.ch","ama611aps.amavita.ch","ama612aps.amavita.ch","ama613aps.amavita.ch","ama614aps.amavita.ch","ama621aps.amavita.ch","ama622aps.amavita.ch","ama623aps.amavita.ch","ama624aps.amavita.ch","ama625aps.amavita.ch","ama626aps.amavita.ch","ama701aps.amavita.ch","ama702aps.amavita.ch","ama703aps.amavita.ch","ama898aps.amavita.ch","ama900aps.amavita.ch","ama988aps.amavita.ch","ama989aps.amavita.ch","cvi243aps.coop-vitality.ch","cvi244aps.coop-vitality.ch","cvi245aps.coop-vitality.ch","cvi246aps.coop-vitality.ch","cvi247aps.coop-vitality.ch","cvi248aps.coop-vitality.ch","cvi250aps.coop-vitality.ch","cvi251aps.coop-vitality.ch","cvi252aps.coop-vitality.ch","cvi253aps.coop-vitality.ch","cvi254aps.coop-vitality.ch","cvi255aps.coop-vitality.ch","cvi256aps.coop-vitality.ch","cvi257aps.coop-vitality.ch","cvi259aps.coop-vitality.ch","cvi260aps.coop-vitality.ch","cvi261aps.coop-vitality.ch","cvi263aps.coop-vitality.ch","cvi264aps.coop-vitality.ch","cvi265aps.coop-vitality.ch","cvi266aps.coop-vitality.ch","cvi267aps.coop-vitality.ch","cvi268aps.coop-vitality.ch","cvi269aps.coop-vitality.ch","cvi271aps.coop-vitality.ch","cvi272aps.coop-vitality.ch","cvi273aps.coop-vitality.ch","cvi275aps.coop-vitality.ch","cvi501aps.coop-vitality.ch","cvi502aps.coop-vitality.ch","cvi505aps.coop-vitality.ch","cvi507aps.coop-vitality.ch","cvi508aps.coop-vitality.ch","cvi801aps.coop-vitality.ch","cvi803aps.coop-vitality.ch","cvi804aps.coop-vitality.ch","cvi805aps.coop-vitality.ch","cvi806aps.coop-vitality.ch","cvi807aps.coop-vitality.ch","cvi809aps.coop-vitality.ch","cvi810aps.coop-vitality.ch","cvi811aps.coop-vitality.ch","cvi812aps.coop-vitality.ch","cvi813aps.coop-vitality.ch","cvi814aps.coop-vitality.ch","cvi815aps.coop-vitality.ch","cvi816aps.coop-vitality.ch","cvi817aps.coop-vitality.ch","cvi818aps.coop-vitality.ch","cvi819aps.coop-vitality.ch","cvi820aps.coop-vitality.ch","cvi821aps.coop-vitality.ch","cvi823aps.coop-vitality.ch","cvi824aps.coop-vitality.ch","cvi825aps.coop-vitality.ch","cvi826aps.coop-vitality.ch","cvi828aps.coop-vitality.ch","cvi829aps.coop-vitality.ch","cvi830aps.coop-vitality.ch","cvi831aps.coop-vitality.ch","cvi832aps.coop-vitality.ch","cvi833aps.coop-vitality.ch","cvi834aps.coop-vitality.ch","cvi835aps.coop-vitality.ch","cvi836aps.coop-vitality.ch","cvi837aps.coop-vitality.ch","cvi838aps.coop-vitality.ch","cvi839aps.coop-vitality.ch","cvi840aps.coop-vitality.ch","cvi841aps.coop-vitality.ch","cvi842aps.coop-vitality.ch","cvi843aps.coop-vitality.ch","cvi844aps.coop-vitality.ch","cvi845aps.coop-vitality.ch","cvi846aps.coop-vitality.ch","cvi847aps.coop-vitality.ch","cvi848aps.coop-vitality.ch","cvi849aps.coop-vitality.ch","cvi851aps.coop-vitality.ch","cvi852aps.coop-vitality.ch","cvi853aps.coop-vitality.ch","cvi854aps.coop-vitality.ch","cvi855aps.coop-vitality.ch","cvi856aps.coop-vitality.ch","cvi858aps.coop-vitality.ch","cvi859aps.coop-vitality.ch","cvi862aps.coop-vitality.ch","cvi863aps.coop-vitality.ch","cvi864aps.coop-vitality.ch","cvi865aps.coop-vitality.ch","cvi866aps.coop-vitality.ch","cvi867aps.coop-vitality.ch","cvi868aps.coop-vitality.ch","cvi869aps.coop-vitality.ch" +$target="ama704aps","ama705aps","ama707aps","cvi503aps","cvi504aps","sun004aps","sun006aps","cvi506aps" +#$target="(local)" +#$target=$null + +if((Test-Path d:\octpdba-662 -PathType Leaf) -ne $true){ + $null = New-Item -ItemType Directory -Force -Path d:\octpdba-662 +} +set-location "d:\octpdba-662" + +$create_concatenated = $false +$glob_csv = ".\all_phcies.csv" + +#remove global csv file if it exists +if(Test-Path $glob_csv -PathType Leaf){ + Remove-Item $glob_csv +} + +#fetch data +if($null -ne $target){ + $target | ForEach-Object -ThrottleLimit 3 -Parallel { + #$target | ForEach-Object { + $instance = "$($_)\apssql" + $csv = "$($_).csv" + $query=" +USE Arizona; + +SELECT CONVERT(DATE, [LCL_value_date]) as LCL_value_date, + [ITK_key], + [ittx].[ITTX_description], + [LCL_calculation] + FROM [Arizona].[dbo].[LORE_calculation_log] WITH (NOLOCK) + JOIN [dbo].[Item_key] WITH (NOLOCK) + ON ITK_item = LCL_item + AND ITK_type = 1 + JOIN [dbo].[Item] IT WITH (NOLOCK) + ON [IT].[Item_ID] = ITK_item + AND [IT].[IT_origin] = 1 + JOIN [dbo].[Item_text] ittx WITH (NOLOCK) + ON [ittx].[ITTX_item] = ITK_item + AND [ittx].[ITTX_language] = 103 + WHERE [LCL_value_date] >= DATEADD(yy, -2, GETDATE()) + ORDER BY CONVERT(DATE, [LCL_value_date]) DESC, + [ITK_key]; +" + + if((Test-Path "$($_).zip") -eq $false){ + Write-Output "Running query on $_" + Invoke-Sqlcmd -Database Arizona -ServerInstance $instance -Query $query -ConnectionTimeout 5 | Export-Csv -Path $csv -Delimiter ";" -NoTypeInformation + Compress-Archive -Path $csv -DestinationPath "$($_).zip" + Remove-Item $csv + #write-output $null >> "$($_).done" + write-output " $csv created." + } + else{ + write-output "$_ already processed, skipping." + } + } + +} + +#concatenate all csv in a big one +write-output "" +if($create_concatenated){ + write-output "Appending all generated CSV in one file..." + Get-ChildItem . -Filter *.csv | ForEach-Object { + Import-Csv -path $_ | export-csv -Append -LiteralPath $glob_csv -NoTypeInformation + Write-Output " ...Appended $_ to $glob_csv" + } +} +write-output "Done." diff --git a/OCTPDBA-662 - Export LORE in CSV format for AI/markers.ps1 b/OCTPDBA-662 - Export LORE in CSV format for AI/markers.ps1 new file mode 100644 index 0000000..df05ff9 --- /dev/null +++ b/OCTPDBA-662 - Export LORE in CSV format for AI/markers.ps1 @@ -0,0 +1,7 @@ +set-location "C:\dev\SSMS projects\OCTPDBA-662 - Export LORE in CSV format for AI" + +Get-ChildItem .\out -Filter *.csv | ForEach-Object { + $n = $_.FullName.replace(".csv", "")+".done" + #write-output $null >> "$($n).done" + Write-Output $null >> $n +} \ No newline at end of file diff --git a/OCTPDBA-662 - Export LORE in CSV format for AI/query.sql b/OCTPDBA-662 - Export LORE in CSV format for AI/query.sql new file mode 100644 index 0000000..67183a7 --- /dev/null +++ b/OCTPDBA-662 - Export LORE in CSV format for AI/query.sql @@ -0,0 +1,20 @@ +USE Arizona; +GO + +SELECT CONVERT(DATE, [LCL_value_date]), + [ITK_key], + [ittx].[ITTX_description], + [LCL_calculation] + FROM [Arizona].[dbo].[LORE_calculation_log] WITH (NOLOCK) + JOIN [dbo].[Item_key] WITH (NOLOCK) + ON ITK_item = LCL_item + AND ITK_type = 1 + JOIN [dbo].[Item] IT WITH (NOLOCK) + ON [IT].[Item_ID] = ITK_item + AND [IT].[IT_origin] = 1 + JOIN [dbo].[Item_text] ittx WITH (NOLOCK) + ON [ittx].[ITTX_item] = ITK_item + AND [ittx].[ITTX_language] = 103 + WHERE [LCL_value_date] >= DATEADD(yy, -2, GETDATE()) + ORDER BY CONVERT(DATE, [LCL_value_date]) DESC, + [ITK_key]; \ No newline at end of file diff --git a/PLAYOFF - delete duplicated address_key.sql b/PLAYOFF - delete duplicated address_key.sql new file mode 100644 index 0000000..5e42b24 --- /dev/null +++ b/PLAYOFF - delete duplicated address_key.sql @@ -0,0 +1,61 @@ +USE [Arizona]; + +IF OBJECT_ID('tempdb..#ADK_KEY_FLA') IS NOT NULL +BEGIN; + DROP TABLE #ADK_KEY_FLA; +END; + +CREATE TABLE #ADK_KEY_FLA +( + ADK_subsidiary INT, + adk_key VARCHAR(50), + adk_type INT +); + +INSERT INTO #ADK_KEY_FLA +SELECT ADK_subsidiary, + ADK_key, + ADK_type +FROM [dbo].[Address_key] +WHERE adk_type = 8 +GROUP BY ADK_subsidiary, + ADK_key, + ADK_type +HAVING COUNT(*) > 1; + +SELECT COUNT(1) AS cnt, + 'local' AS src +FROM dbo.Address_key ADK + INNER JOIN #ADK_KEY_FLA TMP + ON TMP.ADK_subsidiary = ADK.ADK_subsidiary + AND TMP.adk_key = ADK.ADK_key + AND TMP.adk_type = ADK.ADK_type +WHERE [ADK].[ADK_address] > 1500000000 +UNION +SELECT COUNT(1) AS cnt, + 'central' AS src +FROM dbo.Address_key ADK + INNER JOIN #ADK_KEY_FLA TMP + ON TMP.ADK_subsidiary = ADK.ADK_subsidiary + AND TMP.adk_key = ADK.ADK_key + AND TMP.adk_type = ADK.ADK_type +WHERE [ADK].[ADK_address] < 1500000000; + + +BEGIN TRANSACTION; +SET XACT_ABORT ON; +SET NOCOUNT ON; + +DELETE ADK +FROM dbo.Address_key ADK + INNER JOIN #ADK_KEY_FLA TMP + ON TMP.ADK_subsidiary = ADK.ADK_subsidiary + AND TMP.adk_key = ADK.ADK_key + AND TMP.adk_type = ADK.ADK_type +WHERE [ADK].[ADK_address] > 1500000000; +PRINT CONVERT(VARCHAR(20), CURRENT_TIMESTAMP, 114) + ' - adk deleted. ' + + REPLACE(REPLACE(CONVERT(VARCHAR(100), CONVERT(MONEY, @@rowcount), 1), ',', ''''), '.00', '') + + ' row(s) affected.'; + +ROLLBACK TRANSACTION; +--COMMIT TRANSACTION diff --git a/play off/.vs/play off/v15/.ssms_suo b/play off/.vs/play off/v15/.ssms_suo new file mode 100644 index 0000000..dbf1330 Binary files /dev/null and b/play off/.vs/play off/v15/.ssms_suo differ diff --git a/play off/play off.ssmssln b/play off/play off.ssmssln new file mode 100644 index 0000000..7e1ce60 --- /dev/null +++ b/play off/play off.ssmssln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# SQL Server Management Studio Solution File, Format Version 18.00 +VisualStudioVersion = 15.0.28307.421 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{4F2E2C19-372F-40D8-9FA7-9D2138C6997A}") = "play off", "play off\play off.ssmssqlproj", "{1B6FBDA8-E2FE-4779-A62E-49932B62A575}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Default|Default = Default|Default + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1B6FBDA8-E2FE-4779-A62E-49932B62A575}.Default|Default.ActiveCfg = Default + {825E4B3C-1F11-4099-AADE-7F35D6294438}.Default|Default.ActiveCfg = Default + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {28CEC090-D951-474E-9EC4-2DDF05AE1D4D} + EndGlobalSection +EndGlobal diff --git a/play off/play off/play off.ssmssqlproj b/play off/play off/play off.ssmssqlproj new file mode 100644 index 0000000..25cfc75 --- /dev/null +++ b/play off/play off/play off.ssmssqlproj @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file