ALTER Procedure [dbo].[up_InsertNormalizedData]
AS
BEGIN TRAN
BEGIN TRY
/* This procedure loads the InputNems table with normalized data from the ImportData table. The data is normalized
via stored procedure up_NormalizedData. In addition, the normalized date in the InputNems table is then
loaded into the FormattedInputNEMS table where the TSCF field is parsed into the Type, Sector, Category, and FuelType
fields via up_ParseField*/
TRUNCATE TABLE dbo.InputNems
INSERT INTO dbo.InputNEMS (Run, Region ,TSCF, MetricValue, ForecastYear )
exec dbo.up_NormalizeData
TRUNCATE TABLE dbo.FormattedInputNEMS
INSERT INTO dbo.FormattedInputNEMS (Run, Region , TSCF , MetricValue , ForecastYear )
SELECT Run , Region , TSCF , MetricValue , ForecastYear
FROM dbo.InputNEMS ;
EXEC dbo.up_ParseField
COMMIT TRAN
END TRY
BEGIN CATCH
EXEC dbo.usp_err_messages
ROLLBACK TRAN
END CATCH
|