wSeymour
wSeymour

Reputation: 3

Syntax error or access violation, SQL state 37000. MSSQL though ODBC from PHP

I'm trying to execute a stored procedure in a ms sql database using the following php:

$query = "{CALL dbo.storedProc('functionName', $date, 'id";
$resultSet = odbc_prepare($connection, $query);
odbc_execute($resultSet, array());
odbc_result_all($resultSet);

The same stored procedure works fine for a different function, and the results are selected by date like so ($date is @Searchstr):

(EventStart >= @Searchstr AND EventStart < DATEADD(DD,1,@Searchstr))

However, when I run the code, it errors without giving any specific hints as to what's causing the error. When the query is run in management studio, the results are returned correctly.

SQL error: [Microsoft][ODBC SQL Server Driver]Syntax error or access violation, SQL state 37000 in SQLPrepare in ...

What's causing the query to error? Could it be an ODBC bug?

Thanks in advance, Will

Upvotes: 0

Views: 10521

Answers (1)

Joachim Isaksson
Joachim Isaksson

Reputation: 180987

The query seems to be missing ')} at the end.

Upvotes: 1

Related Questions