locked
How do we call sqlsrv_query(), after sqlsrv_prepare()? RRS feed

  • Question

  • Hi,

    I'm doing an INSERT with a Stored Procedure.  Something like this:

    $sql_prep = "EXEC p_1A_insert( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
    $stmt = sqlsrv_prepare($queryLink, $sql_prep, $spParams );

    , and it compiles ok.  But when I do the sqlsrv_execute(), there's an error

    [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near '@P1'.

    , which makes no sense, because there is no variable @P1 in the Stored Procedure.

    It looks like this is due to a bug in the driver, according to another post.  But I don't have the option of changing the driver, since I don't have access to the php server.

    Since this is just a single INSERT statement (that also returns the ID of the new record), I'm trying to use sqlsrv_query().

    I just don't know how to use it, in connection with the 

    $stmt = sqlsrv_prepare($queryLink, $sql_prep, $spParams );

    statement.

    Regards,


    Monday, February 3, 2020 6:38 PM