locked
Incorrect Syntax near ( RRS feed

  • Question

  • User-797751191 posted

    Hi

      ON below line i am getting above error

    Update #tbl1 set CAST(day(@DocDate) AS VARCHAR) = CAST(@Amount AS VARCHAR) WHERE SalesPerson = @SalesPerson and BpName = @BpName

    Thanks

    Monday, July 20, 2020 4:37 PM

Answers

  • User475983607 posted

    Wht should be the correct syntax

    Your code is so poorly written that I have no idea what you're doing!  Again the code tries to assign a value to a value in an  update statement.  It's just wrong.  A column name is required.

    Update #tbl1 set [columnName] = CAST(@Amount AS VARCHAR) 
    WHERE SalesPerson = @SalesPerson 
        and BpName = @BpName

    If the column name is dynamic then you need to write dynamic SQL.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 20, 2020 5:24 PM

All replies

  • User475983607 posted

    Hi

      ON below line i am getting above error

    Update #tbl1 set CAST(day(@DocDate) AS VARCHAR) = CAST(@Amount AS VARCHAR) WHERE SalesPerson = @SalesPerson and BpName = @BpName

    Thanks

    Correct the SQL is invalid.  I can't determine what you are trying to do by reading the code.  As written the code tries to assign a value to a value.

    Monday, July 20, 2020 5:06 PM
  • User-797751191 posted

    Hi mgebhard

       Wht should be the correct syntax

    Thanks

    Monday, July 20, 2020 5:13 PM
  • User475983607 posted

    Wht should be the correct syntax

    Your code is so poorly written that I have no idea what you're doing!  Again the code tries to assign a value to a value in an  update statement.  It's just wrong.  A column name is required.

    Update #tbl1 set [columnName] = CAST(@Amount AS VARCHAR) 
    WHERE SalesPerson = @SalesPerson 
        and BpName = @BpName

    If the column name is dynamic then you need to write dynamic SQL.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 20, 2020 5:24 PM