Stored Procedure WHERE
From: warway (warway_at_hotmail.com)
Date: 11/03/04
- Next message: Roji. P. Thomas: "Re: Identity"
- Previous message: Sri: "Identity"
- Next in thread: avnrao: "Re: Stored Procedure WHERE"
- Reply: avnrao: "Re: Stored Procedure WHERE"
- Reply: Mal .mullerjannie_at_hotmail.com>: "RE: Stored Procedure WHERE"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 3 Nov 2004 12:00:10 -0000
I want to use a store procedure to select records based on a date range but
the date range can be in one of two fields depending on the data in another
field..
So I want to select records with an ETA (@FindDate) within a range
(@StartDate and @EndDate) if the record is an 'Import' (stored in
ServiceDescription), else with an ETS (@FindDate) within the same range.
I get error 156 : Incorrect syntax near word AS
Any pointers in the right direction would be wonderful.
CREATE Procedure dbo.sp_Report1 (@StartDate smalldatetime,@EndDate
smalldatetime,@FindDate smalldatetime)
AS
SELECT *,
CASE WHEN ServiceDescription = 'Import' THEN ETA AS @FindDate
ELSE ETS AS @FindDate
END
FROM dbo.Report1View
WHERE
@FindDate Between @StartDate and @EndDate
return
GO
warway@hotmail.com
- Next message: Roji. P. Thomas: "Re: Identity"
- Previous message: Sri: "Identity"
- Next in thread: avnrao: "Re: Stored Procedure WHERE"
- Reply: avnrao: "Re: Stored Procedure WHERE"
- Reply: Mal .mullerjannie_at_hotmail.com>: "RE: Stored Procedure WHERE"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|