/*

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%'
