USE BI_TEMP
GO
--
TRUNCATE TABLE
DBO.OAKEJ_LSSMETRICV
GO
--
INSERT INTO
DBO.OAKEJ_LSSMETRICV
--
SELECT *
--
FROM
DBO.ATHOMM_LSSMETRICV *******Imported Source Table
---------------------------------------------------------------------------------------------------------
--
IF (SELECT OBJECT_ID ('BI_TEMP.dbo.Shop_LSSMETRICS')) IS NOT NULL
BEGIN
DROP TABLE BI_TEMP.dbo.Shop_LSSMETRICS
END
---------------------------------------------------------------------------------------------------------
SELECT
Regions
,Site
,SHOP_Desc
,Cast(Cast(rptdate as Varchar(8))as smalldatetime) as Report_Date
,jobtime
,dwellhours
,productvty
,pmfailcnt
,getdate() as Log_Date
INTO BI_TEMP.dbo.Shop_LSSMETRICS
FROM BI_TEMP.db

AKEJ_LSSMETRICV Metrics left join
BI_Temp.db

AKEJ_Shop_Master_List Master_List
on Metrics.oasite = Master_List.Site
WHERE
Month(Cast(Cast(rptdate as Varchar(8))as smalldatetime))=Month(GetDate())
Order by
Regions
,Site
,rptdate