ALTER TABLE IB_CUST_PROFILE ADD LAST_LOGIN_DATE_NEW datetime;
ALTER TABLE IB_CUST_PROFILE ADD UPDATED_DATE_NEW datetime;
ALTER TABLE IB_CUST_PROFILE ADD MARITAL_DATE_NEW datetime;
ALTER TABLE IB_CUST_PROFILE ADD CUST_STATUS_DATE_NEW datetime;
ALTER TABLE IB_CUST_PROFILE ADD DECEASED_DATE_NEW datetime;
ALTER TABLE IB_CUST_PROFILE ADD START_RELATIONSHIP_NEW datetime;
ALTER TABLE IB_CUST_PROFILE ADD REVIEW_DATE_NEW datetime;
ALTER TABLE IB_CUST_PROFILE ADD CREATION_DATE_NEW datetime;

UPDATE IB_CUST_PROFILE SET LAST_LOGIN_DATE_NEW = CAST(LAST_LOGIN_DATE AS datetime2);
UPDATE IB_CUST_PROFILE SET UPDATED_DATE_NEW = CAST(UPDATED_DATE AS datetime2);
UPDATE IB_CUST_PROFILE SET MARITAL_DATE_NEW = CAST(MARITAL_DATE AS datetime2);
UPDATE IB_CUST_PROFILE SET CUST_STATUS_DATE_NEW = CAST(CUST_STATUS_DATE AS datetime2);
UPDATE IB_CUST_PROFILE SET DECEASED_DATE_NEW = CAST(DECEASED_DATE AS datetime2);
UPDATE IB_CUST_PROFILE SET START_RELATIONSHIP_NEW = CAST(START_RELATIONSHIP AS datetime2);
UPDATE IB_CUST_PROFILE SET REVIEW_DATE_NEW = CAST(REVIEW_DATE AS datetime2);
UPDATE IB_CUST_PROFILE SET CREATION_DATE_NEW = CAST(CREATION_DATE AS datetime2);

ALTER TABLE IB_CUST_PROFILE DROP COLUMN LAST_LOGIN_DATE;
ALTER TABLE IB_CUST_PROFILE DROP COLUMN UPDATED_DATE;
ALTER TABLE IB_CUST_PROFILE DROP COLUMN MARITAL_DATE;
ALTER TABLE IB_CUST_PROFILE DROP COLUMN CUST_STATUS_DATE;
ALTER TABLE IB_CUST_PROFILE DROP COLUMN DECEASED_DATE;
ALTER TABLE IB_CUST_PROFILE DROP COLUMN START_RELATIONSHIP;
ALTER TABLE IB_CUST_PROFILE DROP COLUMN REVIEW_DATE;
ALTER TABLE IB_CUST_PROFILE DROP COLUMN CREATION_DATE;

EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.LAST_LOGIN_DATE_NEW',
    @newname = 'LAST_LOGIN_DATE',
    @objtype = 'COLUMN';
EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.UPDATED_DATE_NEW',
    @newname = 'UPDATED_DATE',
    @objtype = 'COLUMN';
EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.MARITAL_DATE_NEW',
    @newname = 'MARITAL_DATE',
    @objtype = 'COLUMN';
EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.CUST_STATUS_DATE_NEW',
    @newname = 'CUST_STATUS_DATE',
    @objtype = 'COLUMN';
EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.DECEASED_DATE_NEW',
    @newname = 'DECEASED_DATE',
    @objtype = 'COLUMN';
EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.START_RELATIONSHIP_NEW',
    @newname = 'START_RELATIONSHIP',
    @objtype = 'COLUMN';
EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.REVIEW_DATE_NEW',
    @newname = 'REVIEW_DATE',
    @objtype = 'COLUMN';
EXEC sp_rename
    @objname = 'IB_CUST_PROFILE.CREATION_DATE_NEW',
    @newname = 'CREATION_DATE',
    @objtype = 'COLUMN';

UPDATE IB_CUST_PROFILE SET LAST_LOGIN_DATE = (SELECT getdate()) WHERE LAST_LOGIN_DATE IS NULL;
UPDATE IB_CUST_PROFILE SET UPDATED_DATE = (SELECT getdate()) WHERE UPDATED_DATE IS NULL;
