use master 

RESTORE DATABASE [Arizona_delphix] FROM [Arizona_dump_secu] WITH  FILE = 1, REPLACE, MOVE N'Arizona_Data' TO N'F:\SQLDataBase\Arizona_delphix.mdf',  MOVE N'Arizona_Log' TO N'G:\SQLDataBase\Arizona_delphix_1.ldf',  NOUNLOAD,  STATS = 5;

ALTER DATABASE [Arizona_delphix] SET RECOVERY SIMPLE WITH ROLLBACK IMMEDIATE;

ALTER DATABASE arizona_delphix SET ALLOW_SNAPSHOT_ISOLATION ON  
ALTER DATABASE arizona_delphix SET READ_COMMITTED_SNAPSHOT ON  
EXEC hciTools.[delphix].[delphix_schema_changes] @removeSchemaChanges = 0


select 'az' as src, *
from arizona.information_schema.columns c
where c.table_name ='address'
and c.column_name = 'tt_masking'

if @@rowcount > 0 
begin 
    print 'drop default constraint and columns tt_masking on arizona'
    alter table arizona.dbo.address drop constraint df_tt_masking
    alter table arizona.dbo.address drop column tt_masking
end 

use master

select 'az_delphix' as src, *
from arizona_delphix.information_schema.columns c
where c.table_name ='address'
and c.column_name = 'tt_masking'

select tt_masking, COUNT(1)
from Arizona_delphix.dbo.address a
group by tt_masking


return



--use arizona_delphix
--ALTER TABLE arizona_delphix.AP.WebShopStatusQueue DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.DL_posology DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Document_header DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Document_line DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Document_line_link DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Item_inventory DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Item_quantity DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Item_seasonal_stock_info DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Item_standard_cost DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.LORE_item_ABC_code DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.LORE_supplying_procedure DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.PH_insurance_card DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.PH_insurance_plan DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.PH_insurance_recommendation DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.PH_patient DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.PH_prescription_header DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.PH_prescription_line DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.dbo.Price_modifier DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.DocumentSignature DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.GoodsReceipt DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.GoodsReceiptLine DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.MissedSale DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.OrderRequest DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.OrderRequestLine DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.PurchaseReturn DISABLE CHANGE_TRACKING;
--ALTER TABLE arizona_delphix.wkl.PurchaseReturnLine DISABLE CHANGE_TRACKING;

--alter table arizona_delphix.[wkl].[DeliveryNote] drop constraint [FK_DeliveryNote_Supplier];
