I have the following stored procedure:
DECLARE @BeginDate1 datetime, @EndDate1 datetime
set @BeginDate1 = '04-01-2012'
set @EndDate1 = '03-31-2013'
BEGIN
INSERT INTO MTBUR_Type_Stage
SELECT
R.Type, [Hours],
LEFT(dbo.fn_GetPartName(R.PartID),CHARINDEX('-',dbo.fn_GetPartName(R.ACSS_PartID), 1) - 1) AS 'Part No',
Count(s.status) AS NumberUnscheduled,
([Hours]/Count(s.status)) AS MTBUR
FROM
Repair R
INNER JOIN
Conversion C ON (R.Performed = C.Performed)
AND (R.Confirmed = C.Confirmed)
INNER JOIN
Status S ON C.StatusID = S.StatusID
INNER JOIN
#MTBUR_Hrs_Temp TEMP ON LEFT(dbo.fn_GetPartName(R.PartID),CHARINDEX('-',dbo.fn_GetPartName(R.PartID), 1) - 1) = TEMP.productNo
AND R.Type = TEMP.Type
WHERE
(R.Received BETWEEN @BeginDate1 AND @EndDate1)
AND (S.Status = 'UNSCHEDULED')
GROUP BY
LEFT(dbo.fn_GetPartName(R.PartID),CHARINDEX('-',dbo.fn_GetPartNaame(R.PartID), 1) - 1), [Hours], R.Type
ORDER BY
R.Type,
LEFT(dbo.fn_GetPartName(R.ACSS_PartID),CHARINDEX('-',dbo.fn_GetPartID(R.PartID), 1) - 1) ASC
DROP TABLE #MTBUR_Hrs_Temp
END
The table being inserted to (MTBUR_Type_Stage) has columns named EndingDate and EndingQuarter. EndingDate needs to have the same date (constant) which is equal to @EndDate and EndingQuarter needs to have a constant value of 1
How can I script this in my stored procedure so that ALL rows are populated with these constants in the relevant columns in MTBUR_Type_Stage are populated with these constants?
The following is the DDL for the table I am inserting into:
CREATE TABLE [dbo].[MTBUR_ByType_StageTbl]
(
[Type] [nvarchar](25) NULL,
[Hours] [float] NULL,
[Part No] [varchar](15) NULL,
[UnscheduledRemovals] [int] NULL,
[MTBUR] [float] NULL,
[EndingDate] [datetime] NULL,
[EndingQuarter] [int] NULL
) ON [PRIMARY]