Can someone tell me why I get error: Msg 207, Level 16, State 1, Procedure ExtractPDP4FromPDP, Line 21 Invalid column name 'ContainsEX'.
when executing the following stored procedure.
CREATE PROCEDURE ExtractPDP4FromPDP
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT PDP.*, LEFT(PDPCode,7) AS PDP7, PDP.Obsolete,
PDP.InvestorPDP, PDP.OnlineReport, PDP.ClientSpecific,
ContainsEX = CASE
WHEN(CHARINDEX(Left(PDPCode,5),'EX')>0) THEN 'True'
ELSE 'False'
END, PDP4 =
CASE
WHEN ContainsEX = 'True' THEN 'E' & SUBSTRING(pdpcode,5,3)
ELSE SUBSTRING(pdpcode,6,3)
END
FROM PDP
WHERE (((PDP.Obsolete)='False') AND ((PDP.InvestorPDP)='True') AND
((PDP.OnlineReport)='False') AND ((PDP.ClientSpecific)='False'));
END
GO
Thank You in advance