IF EXISTS(
    SELECT * FROM sys.columns 
    WHERE Name = N'ValueDate' AND Object_ID = Object_ID(N'BA_Metadata') and system_type_id <> 43)
BEGIN
	EXEC sp_rename '[dbo].BA_Metadata.ValueDate', 'ValueDateOld', 'COLUMN';
	ALTER TABLE [dbo].BA_Metadata ADD ValueDate DATETIMEOFFSET (7) NULL;
END;
--select xtype from sys.systypes where name='datetimeoffset'