Incorrect syntax near the keyword 'THEN'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ielmrani via SQLMonster.com

    Incorrect syntax near the keyword 'THEN'

    Hi Everyone,
    I really tried to not post this question but I gave up. I tried brackets,
    parenth...etc but nothing worked. I get this error message: Incorrect syntax
    near the keyword 'THEN'. Please help, I am learning SQL Server.
    thanks in advance.
    Ismail

    use mis
    select CLAIM_DETAILS_H CVW.INTEREST, CLAIM_DETAILS_H CVW.NET, CLAIM_HMASTERS_ VS.

    CLAIMNO,
    'AMOUNT' =
    CASE WHEN (CLAIM_DETAILS_ HCVW.INTEREST IS NULL THEN '0' ELSE
    CLAIM_DETAILS_H CVW.INTEREST + CLAIM_DETAILS_H CVW.NET)
    END,

    FROM CLAIM_HMASTERS INNER JOIN CLAIM_HMASTERS ON CLAIM_HMASTERS_ VS.CLAIMNO =
    CLAIM_DETAILS_H CVW.CLAIMNO

    where CLAIM_HMASTERS_ VS.CLAIMNO like '200601119%'

    --
    Message posted via SQLMonster.com
    Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.


  • Jack Vamvas

    #2
    Re: Incorrect syntax near the keyword 'THEN'

    Try putting the ELSE part out of the brackets
    i.e
    CASE
    WHEN (CLAIM_DETAILS_ HCVW.INTEREST IS NULL THEN '0' )
    ELSE CLAIM_DETAILS_H CVW.INTEREST + CLAIM_DETAILS_H CVW.NET
    END
    --
    ----
    Jack Vamvas
    _______________ _______________ _____
    Receive free SQL tips - www.ciquery.com/sqlserver.htm
    Make SQL Server faster - www.quicksqlserver.com
    _______________ _______________ _____


    "ielmrani via SQLMonster.com" <u21259@uwewrot e in message
    news:65279dafaa 057@uwe...
    Hi Everyone,
    I really tried to not post this question but I gave up. I tried brackets,
    parenth...etc but nothing worked. I get this error message: Incorrect
    syntax
    near the keyword 'THEN'. Please help, I am learning SQL Server.
    thanks in advance.
    Ismail
    >
    use mis
    select CLAIM_DETAILS_H CVW.INTEREST, CLAIM_DETAILS_H CVW.NET,
    CLAIM_HMASTERS_ VS.
    >
    CLAIMNO,
    'AMOUNT' =
    CASE WHEN (CLAIM_DETAILS_ HCVW.INTEREST IS NULL THEN '0' ELSE
    CLAIM_DETAILS_H CVW.INTEREST + CLAIM_DETAILS_H CVW.NET)
    END,
    >
    FROM CLAIM_HMASTERS INNER JOIN CLAIM_HMASTERS ON CLAIM_HMASTERS_ VS.CLAIMNO
    =
    CLAIM_DETAILS_H CVW.CLAIMNO
    >
    where CLAIM_HMASTERS_ VS.CLAIMNO like '200601119%'
    >
    --
    Message posted via SQLMonster.com

    >
    >

    Comment

    • ielmrani via SQLMonster.com

      #3
      Re: Incorrect syntax near the keyword 'THEN'

      That's it. Thank you so much.
      Jack Vamvas wrote:
      >Try putting the ELSE part out of the brackets
      >i.e
      >CASE
      >WHEN (CLAIM_DETAILS_ HCVW.INTEREST IS NULL THEN '0' )
      >ELSE CLAIM_DETAILS_H CVW.INTEREST + CLAIM_DETAILS_H CVW.NET
      >END
      >--
      >----
      >Jack Vamvas
      >______________ _______________ ______
      >Receive free SQL tips - www.ciquery.com/sqlserver.htm
      >Make SQL Server faster - www.quicksqlserver.com
      >______________ _______________ ______
      >
      >Hi Everyone,
      >I really tried to not post this question but I gave up. I tried brackets,
      >[quoted text clipped - 20 lines]
      >Message posted via SQLMonster.com
      >http://www.sqlmonster.com/Uwe/Forums...neral/200608/1
      --
      Message posted via SQLMonster.com
      Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.


      Comment

      Working...