Results 1 to 2 of 2

Thread: Stored Proc

  1. #1
    Join Date
    Apr 2004
    Posts
    1

    Red face Unanswered: Stored Proc

    i know this might seem a bit stupid to ask - but how do i use IF statements in sql?

    i'm having difficulty incorporating statements like :

    if @date in (csfsc.bgndate1) to (csfsc.enddate1) then 1 else
    if @date in (csfsc.bgndate10)to (csfsc.enddate10) then 10 else
    if @date in (csfsc.bgndate11) to (csfsc.enddate11) then 11 else
    if @date in (csfsc.bgndate12) to (csfsc.enddate12) then 12 else

    into my query...where should this go?

    PLZ HELP!!!!

    kind regards

  2. #2
    Join Date
    Mar 2004
    Location
    West London
    Posts
    34
    You could use IF or CASE

    IF:

    IF @date BETWEEN db.startdate and db.enddate
    BEGIN
    'do something here
    END
    ELSE
    BEGIN
    'do something else here
    END



    or


    CASE:
    DECLARE @VALUE int
    SELET @value =
    CASE
    WHEN@date BETWEEN db.startdate AND db.enddate THEN 1
    WHEN @date BETWEEN db.startdate1 AND db.enddate1 THEN 10

    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •