sync state
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -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
|
||||
24
DBG - GAIA - check routes after playoffs.sql
Normal file
24
DBG - GAIA - check routes after playoffs.sql
Normal file
@@ -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%'
|
||||
@@ -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)
|
||||
|
||||
|
||||
7
DBG - check assemblies signature.sql
Normal file
7
DBG - check assemblies signature.sql
Normal file
@@ -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
|
||||
8
DBG - cleanup gaia for 1 phcy_code.sql
Normal file
8
DBG - cleanup gaia for 1 phcy_code.sql
Normal file
@@ -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'
|
||||
;
|
||||
|
||||
17
DBG - craft cmds to move tempdb files.sql
Normal file
17
DBG - craft cmds to move tempdb files.sql
Normal file
@@ -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];
|
||||
@@ -19,7 +19,7 @@ https://www.sqlservercentral.com/forums/topic/how-to-import-replication-monitor-
|
||||
</PublisherGroups>
|
||||
|
||||
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)='
|
||||
<Distributor>@srv@\@inst@</Distributor>
|
||||
<Interval>5</Interval>
|
||||
<AutoRefresh>True</AutoRefresh>
|
||||
<AutoConnect>True</AutoConnect>
|
||||
<AutoConnect>False</AutoConnect>
|
||||
<IsOraclePublisher>False</IsOraclePublisher>
|
||||
<LastSelectedAgentType>Snapshot Agent</LastSelectedAgentType>
|
||||
<LastSelectedFilterType>0</LastSelectedFilterType>
|
||||
@@ -43,7 +43,7 @@ DECLARE @tplDis VARCHAR(MAX)='
|
||||
<DistributorsSetting Name="@srv@\@inst@">
|
||||
<Interval>5</Interval>
|
||||
<AutoRefresh>True</AutoRefresh>
|
||||
<AutoConnect>True</AutoConnect>
|
||||
<AutoConnect>False</AutoConnect>
|
||||
<LastSelectedAgentType>Snapshot Agent</LastSelectedAgentType>
|
||||
<LastSelectedFilterType>0</LastSelectedFilterType>
|
||||
<LastSelectedPubType>-1</LastSelectedPubType>
|
||||
|
||||
2
DBG - disable all jobs.sql
Normal file
2
DBG - disable all jobs.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
select 'exec msdb.dbo.sp_update_job @job_name='''+name+''', @enabled = 0'
|
||||
from msdb.dbo.sysjobs
|
||||
7
DBG - disable all logins.sql
Normal file
7
DBG - disable all logins.sql
Normal file
@@ -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
|
||||
121
DBG - extract db mail settings.sql
Normal file
121
DBG - extract db mail settings.sql
Normal file
@@ -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
|
||||
158
DBG - syncro H debug.sql
Normal file
158
DBG - syncro H debug.sql
Normal file
@@ -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
|
||||
|
||||
24
EXPLOIT - Commvault restore via CLR.sql
Normal file
24
EXPLOIT - Commvault restore via CLR.sql
Normal file
@@ -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
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -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]
|
||||
Binary file not shown.
Binary file not shown.
@@ -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]
|
||||
|
||||
@@ -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], '<All>' 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], '<All>' as [Code_name], null as [Company] from CostCenter
|
||||
union
|
||||
SELECT 2 as Position, null as [Code], '<All>' 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
|
||||
-----------------
|
||||
|
||||
*/
|
||||
107
OCTPDBA-662 - Export LORE in CSV format for AI/extract.ps1
Normal file
107
OCTPDBA-662 - Export LORE in CSV format for AI/extract.ps1
Normal file
File diff suppressed because one or more lines are too long
@@ -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
|
||||
}
|
||||
20
OCTPDBA-662 - Export LORE in CSV format for AI/query.sql
Normal file
20
OCTPDBA-662 - Export LORE in CSV format for AI/query.sql
Normal file
@@ -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];
|
||||
61
PLAYOFF - delete duplicated address_key.sql
Normal file
61
PLAYOFF - delete duplicated address_key.sql
Normal file
@@ -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
|
||||
BIN
play off/.vs/play off/v15/.ssms_suo
Normal file
BIN
play off/.vs/play off/v15/.ssms_suo
Normal file
Binary file not shown.
22
play off/play off.ssmssln
Normal file
22
play off/play off.ssmssln
Normal file
@@ -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
|
||||
9
play off/play off/play off.ssmssqlproj
Normal file
9
play off/play off/play off.ssmssqlproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="SqlWorkbenchSqlProject">
|
||||
<Items>
|
||||
<LogicalFolder Name="Connections" Type="2" />
|
||||
<LogicalFolder Name="Queries" Type="0" />
|
||||
<LogicalFolder Name="Miscellaneous" Type="3" />
|
||||
|
||||
</Items>
|
||||
</SqlWorkbenchSqlProject>
|
||||
Reference in New Issue
Block a user