BobThornton
Programmer
Please see the query below. When I run the Insert Into... by itself, it runs, but when I run the entire query it fails with - Column name or number of supplied values does not match table definition.
I'm trying to automate this query is why I have the T1 and T2. Thanks in advance for all of your help!
; WITH T1 AS (
SELECT *
FROM PPNO_DB.dbo.REF_CALENDAR
WHERE
YEAR = YEAR(GETDATE())
AND
MTH = MONTH(GETDATE())
AND DATE_DAY = 'Monday'
AND
RIGHT(DATE,2) BETWEEN '06' AND '13'
)
, T2 AS (
SELECT *,
CASE
WHEN CONVERT(DATE, GETDATE()) = T1.DATE
THEN 1
ELSE 0
END AS CHECK_DATE
FROM T1
)
--003_PNV_MMA_Networkdata Refresh Process
INSERT INTO AdHocData.MDCOutEd.PNV_MMA_NetworkData_Hist
SELECT *
FROM AdHocData.MDCOutEd.PNV_MMA_NetworkData_Curr
CROSS JOIN T2
WHERE T2.CHECK_DATE != '0'
I'm trying to automate this query is why I have the T1 and T2. Thanks in advance for all of your help!
; WITH T1 AS (
SELECT *
FROM PPNO_DB.dbo.REF_CALENDAR
WHERE
YEAR = YEAR(GETDATE())
AND
MTH = MONTH(GETDATE())
AND DATE_DAY = 'Monday'
AND
RIGHT(DATE,2) BETWEEN '06' AND '13'
)
, T2 AS (
SELECT *,
CASE
WHEN CONVERT(DATE, GETDATE()) = T1.DATE
THEN 1
ELSE 0
END AS CHECK_DATE
FROM T1
)
--003_PNV_MMA_Networkdata Refresh Process
INSERT INTO AdHocData.MDCOutEd.PNV_MMA_NetworkData_Hist
SELECT *
FROM AdHocData.MDCOutEd.PNV_MMA_NetworkData_Curr
CROSS JOIN T2
WHERE T2.CHECK_DATE != '0'