Re: Using CASE statement to build different where clause
From: NWx (test_at_test.com)
Date: 03/17/04
- Next message: bobcatmike: "Re: msde installation operation failed on Win XP"
- Previous message: MJJ: "Re: New to MSDE and SQL server"
- In reply to: NWx: "Using CASE statement to build different where clause"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 17 Mar 2004 02:10:46 +0200
Thank you for all your answers!
"NWx" <test@test.com> wrote in message
news:Oa7MM46CEHA.2616@TK2MSFTNGP12.phx.gbl...
> HI,
>
> Is it possible to use CASE statement to select a different where clause in
a
> SQL statement?
>
> What I try to accomplish is this:
>
> I have a table, with a smalldatetime field
>
> I want to create a stored proc, which can receive two parameters, start
and
> end date
> If parameters are present (not null I suppose), I want to select records
> between those dates.
> Otherwise I want to select all records
>
> My stored proc looks as follows:
>
> ALTER Procedure GetNotifications
>
> (
>
> @StartDT smalldatetime,
>
> @EndDT smalldatetime
>
> )
>
> As
>
> set nocount on
>
> select * from Notifications
>
> CASE
>
> when @StartDT IS NOT NULL
>
> where notify_date between @StartDT and @EndDT
>
> END
>
> return
>
>
>
> But I cannot save it, I get the following error (in Access ADP)
>
> "Incorrect syntax near the keyword 'CASE'"
>
> How can I accomplish what I need?
>
>
>
> Thank you
>
>
>
>
>
>
>
>
>
- Next message: bobcatmike: "Re: msde installation operation failed on Win XP"
- Previous message: MJJ: "Re: New to MSDE and SQL server"
- In reply to: NWx: "Using CASE statement to build different where clause"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|