\\VADER\SourceData\IMPROVE\RHR_And_Impairment\RHR2
folder.USE AIRDATA_IMPORT
GO
EXEC bspImportDatasetItem
@SourceName = 'INA_IMPAIRMENT_DAILY_BUDGETS_ALL_R20170830',
@SourceFormat = 'CSV File',
@SourceLastModifiedDate = '8/30/2017',
@SourceAcquisitionDate = '9/15/2017',
@SourceDataUri = 'https://drive.google.com/drive/folders/0Bxfj1vyyXeDYWVpfeUo4NEYtTU0',
@LocalDataUri = '\\VADER\SourceData\IMPROVE\RHR_And_Impairment\RHR3_Impairment\R20170915\sia_impairment_daily_budgets_8_17.csv',
@DatasetItemName ='INA_IMPAIRMENT_DAILY_BUDGETS_ALL_R20170830',
@DatasetID = 10006,
@ProtocolID = 1006,
@ImportedBy = 'SEM',
@ImportLog = '\\JARVIS\E\DevSystems\EDMF\Edmf.Database\Data Import\IMPROVE\Impairment_Copeland\_ImportLogs\bssImportMaster_IMPIMP_All_Years_Initial_20170921.sql',
@Comments = 'Re-import of the updated impairment dataset after Scott Copeland''s revisions; See his email of Thu 8/31/2017 10:22 AM',
@ArgKeys = '@SourceFile',
@ArgValues = 'E:\SourceData\IMPROVE\RHR_And_Impairment\RHR3_Impairment\R20170915\sia_impairment_daily_budgets_8_17.csv',
@ShowProgress = 1,
@AbortOnSiteMappingError = 1,
@AbortOnParameterMappingError = 1,
@AbortOnMethodMappingError = 1,
@AbortOnFlagMappingError = 1,
@KeepSource = 1,
@KeepTempTables = 1,
@UpdateStatistics = 1,
@OutputTableName ='AirFact_INA_IMPAIRMENT_DAILY_BUDGETS_ALL_R20170830'
USE AIRDATA_IMPORT
GO
EXEC bspImportDatasetItem
@SourceName = 'INA_IMPAIRMENT_GROUP_MEANS_ALL_R20170830',
@SourceFormat = 'CSV File',
@SourceLastModifiedDate = '8/30/2017',
@SourceAcquisitionDate = '9/15/2017',
@SourceDataUri = 'https://drive.google.com/drive/folders/0Bxfj1vyyXeDYWVpfeUo4NEYtTU0',
@LocalDataUri = '\\VADER\SourceData\IMPROVE\RHR_And_Impairment\RHR3_Impairment\R20170915\sia_impairment_group_means_8_17.csv',
@DatasetItemName ='INA_IMPAIRMENT_GROUP_MEANS_ALL_R20170830',
@DatasetID = 10006,
@ProtocolID = 1007,
@ImportedBy = 'SEM',
@ImportLog = '\\JARVIS\E\DevSystems\EDMF\Edmf.Database\Data Import\IMPROVE\Impairment_Copeland\_ImportLogs\bssImportMaster_IMPIMP_All_Years_Initial_20170921.sql',
@Comments = 'Re-import of the updated impairment dataset after revisions by Scott Copeland; See his email of Thu 8/31/2017 10:22 AM',
@ArgKeys = '@SourceFile',
@ArgValues = 'E:\SourceData\IMPROVE\RHR_And_Impairment\RHR3_Impairment\R20170915\sia_impairment_group_means_8_17.csv',
@ShowProgress = 1,
@AbortOnSiteMappingError = 1,
@AbortOnParameterMappingError = 1,
@AbortOnMethodMappingError = 1,
@AbortOnFlagMappingError = 1,
@KeepSource = 1,
@KeepTempTables = 1,
@UpdateStatistics = 1,
@OutputTableName ='AirFact_INA_IMPAIRMENT_GROUP_MEANS_ALL_R20170830'
DELETE FROM AIRDATA_CORE.dbo.AirFact WHERE DatasetID = 10006 -- took 1:36:48 hours; (30642942 row(s) affected)
-- ^^ The above command is an example of replacing the *entire* RHR2 dataset.
In many (most) cases, new RHR2 data will simply be added to the production AirFact table, and no DELETE command will be necessary. But when updated data is intended to replace previous data, a date-range-specific DELETE command will be needed to do a more precision replacement.
Below is an example of deleting a single year of previous data:
DELETE FROM AIRDATA_CORE.dbo.AirFact WHERE DatasetID = 10006 AND YEAR(FactDate) = 2016
And here is an example of deleting three months of data:
DELETE FROM AirFact WHERE DatasetID = 10006 AND ((FactDate >= '6/1/2016') AND (FactDate < '9/1/2016')) -- Deleting 3 months of data (June, July, and August)
USE AIRDATA_CORE
GO
EXEC bspUpdate_Dataset_Site @DatasetID=10006 -- took 9:31 minutes
--Done deleting previous Dataset_Site records for DatasetID 10006 (195 records deleted); Elapsed time: 0 minutes;
--Done inserting new Dataset_Site records for DatasetID 10006 (163 records inserted); Elapsed time: 9 minutes;
EXEC bspUpdate_Dataset_Parameter @DatasetID=10006 -- took 2:32 minutes
--Done deleting previous Dataset_Parameter records for DatasetID 10006 (102 records deleted); Elapsed time: 0 minutes;
--Done inserting new Dataset_Parameter records for DatasetID 10006 (104 records inserted); Elapsed time: 2 minutes;
EXEC bspUpdate_Dataset_Aggregation @DatasetID=10006 -- took 40 seconds
--Done deleting previous Dataset_Aggregation records for DatasetID 10006 (7 records deleted); Elapsed time: 0 minutes;
--Done inserting new Dataset_Aggregation records for DatasetID 10006 (7 records inserted); Elapsed time: 1 minutes;