CREATE PROCEDURE [dbo].[create_dim_rmg_pipeline_status_reasons_master] AS BEGIN

    DROP TABLE IF EXISTS dim_rmg_pipeline_status_reasons_master;
	CREATE TABLE dim_rmg_pipeline_status_reasons_master
	(
		id INT NOT NULL,
		demand_status VARCHAR(255) NOT NULL,
		reason varchar(255) NULL,
		reason_type int NULL,
		is_active bit default 0
	);
	CREATE INDEX dim_rmg_pipeline_status_reasons_master_id_index ON dim_rmg_pipeline_status_reasons_master (id);

    INSERT INTO dim_rmg_pipeline_status_reasons_master
	SELECT id,
		demand_status,reason, reason_type, is_active
		from rmg_pipeline_status_reasons_master;


	UPDATE last_updated_at_history SET last_updated_at = GETDATE() WHERE sp_name = 'create_dim_rmg_pipeline_status_reasons_master';

END
go

