QUERY ERROR

  • hI,

    I HAVE TRIS CODE:

    SET @STRSQL = ('UPDATE BULK_CONTRIBUINTES_21

    SET VALIDO_BULK = 0,

    MOTIVO_IRREGULAR_BULK =''NIF''

    FROM

    BULK_CONTRIBUINTES_21 A, '+@DB+'.DBO.CONTRIBUINTES B

    WHERE

    A.NIF+ISNULL(A.FILIAL_NUMBER,'') = B.NIF+ISNULL(B.FILIAL_NUMBER,'')

    AND

    A.NIF_ANTIGO <> B.NIF_ANTIGO

    AND

    A.VALIDO_BULK IS NULL')

    EXEC (@STRSQL)

    I RECEIVE THE FOLLOWING ERROR:

    Msg 4145, Level 15, State 1, Line 14

    An expression of non-boolean type specified in a context where a condition is expected, near 'AND'.

    CAN SOMEONE HELP?

    TKS

  • A.NIF+ISNULL(A.FILIAL_NUMBER,'') = B.NIF+ISNULL(B.FILIAL_NUMBER,'')

    A.NIF+ISNULL(A.FILIAL_NUMBER,'''') = B.NIF+ISNULL(B.FILIAL_NUMBER,'''')

    you didn't account for using quotes inside your dynamic sql

    MVDBA

  • THANKS

  • river1 (6/8/2012)


    ...

    CAN SOMEONE HELP?

    TKS

    Yes - always PRINT the string to see exactly what is generated by your code.

    Simple.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply