Reputation: 2876
I am tracking mysql errors using the function mysql_error
that everyone knows. But, I am accessing records from SQL Server, For that i have used all the mssql_
functions which are provided by PHP.
One of my queries is not getting executed and am not sure where i did the mistake. Can any one please tell me, what is the exact function for SQL Server to track the DB errors(available in PHP).
SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc
Upvotes: 4
Views: 3318
Reputation: 4301
Unfortunately, there is no error function in SQL Server. Instead, use mssql_get_last_message()
.
Upvotes: 6
Reputation: 1
SELECT * FROM gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc
This can never work, as you are using the GROUP BY clause. You will need to specify which fields to show. So something like:
SELECT
postalcode, region3
FROM
gb
WHERE
postalcode LIKE 'YO1%' OR place LIKE 'YO1%'
GROUP BY
postalcode, region3
ORDER BY
postalcode ASC
Upvotes: 0
Reputation: 620
This is a simple select sql. I would want to run this in SQL Server Management Studio, if I were you. Apart from that, try this link http://www.php.net/manual/en/function.mssql-get-last-message.php#21728 where someone has tried to resolve issues using a GENERIC ERROR HANDLING Stored Procedure.
Upvotes: 1