#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    MS Query returns sql error on when SSRS doesn't


    I've written a t-sql query against a SLQ Server 2008 db which works error free when I run it in SSRS. However, when I run it in MS Query (via Excel) I get an error.

    The specific line that it throws an error on is:

    ( CASE glfeeddetail.entrytype WHEN 1 THEN GLFEEDDETAIL.Amount * -1
    ELSE GLFEEDDETAIL.Amount
    END ) AS GL_Amt,

    The error is 'INCORRECT COLUMN EXPRESSION'

    I also tried putting the expression in this alternative syntax but I still got the same error:

    ( CASE WHEN glfeeddetail.entrytype = 1 THEN GLFEEDDETAIL.Amount * -1
    ELSE GLFEEDDETAIL.Amount
    END ) AS GL_Amt,

    FYI, I also tried this as a 'Pass through Query' in MS Access 2010 and I got a slightly different error on the same line stating:

    'Syntax Error ( missing operator) in query expression.'

    Can anyone shed light as to why I would get this error in MS QUERY when the query runs fine in SSRS? I thought any query that runs in one product would run in the other. Do I need to write a slightly different brand of SQL when I'm in MS QUERY?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    120
    Rep Power
    10
    you got error because SQL server, MS Access 2010 and MS Query (via Excel) has slightly different syntactic...

IMN logo majestic logo threadwatch logo seochat tools logo