Results 1 to 3 of 3

Thread: Another sql statement problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2001
    Posts
    759

    Another sql statement problem

    Hi Everyone,

    What is wrong with this sql statement? I keep getting an error saying that there is an incorrect syntax near the '=' sign. I would appreciate any help. Thank you.

    Code:
    SELECT     MemID, MemName, (CASE WHEN PayCredit = AppRes THEN PayCredit = NULL 
                          ELSE PayCredit - AppRes END) AS AppliedCredit, (CASE WHEN AppRes = 0 THEN AppRes = NULL 
                          ELSE AppRes END) AS CreditReserve
    FROM         Archive
    WHERE     PDate BETWEEN CAST('" & DTPicker1.Value & "' AS smalldatetime) AND CAST('" & DTPicker2.Value & "' AS smalldatetime) AND 
                          PayCredit <> 0 AND PayCredit <> DedRes
    ORDER BY ID

  2. #2
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724

    Re: Another sql statement problem

    Originally posted by Ace
    Hi Everyone,

    What is wrong with this sql statement? I keep getting an error saying that there is an incorrect syntax near the '=' sign. I would appreciate any help. Thank you.

    Code:
    SELECT     MemID, MemName, (CASE WHEN PayCredit = AppRes THEN PayCredit = NULL 
                          ELSE PayCredit - AppRes END) AS AppliedCredit, (CASE WHEN AppRes = 0 THEN AppRes = NULL 
                          ELSE AppRes END) AS CreditReserve
    FROM         Archive
    WHERE     PDate BETWEEN CAST('" & DTPicker1.Value & "' AS smalldatetime) AND CAST('" & DTPicker2.Value & "' AS smalldatetime) AND 
                          PayCredit <> 0 AND PayCredit <> DedRes
    ORDER BY ID
    is ur paycredit a numeric ... if so it cannot accept null. it shd be 0
    try changing the null to 0

  3. #3
    Member
    Join Date
    Nov 2001
    Location
    Virginia
    Posts
    58
    you cannot use
    Code:
     var1 = NULL
    in SQL. You must use
    Code:
     var1 is NULL
    hope that helps

Posting Permissions

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



Click Here to Expand Forum to Full Width