开发者

PHP SQL Server error tracking

开发者 https://www.devze.com 2023-03-08 13:20 出处:网络
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.

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开发者_Python百科 gb WHERE postalcode like 'YO1%' OR place like 'YO1%' group by postalcode, region3 order by postalcode asc


Unfortunately, there is no error function in SQL Server. Instead, use mssql_get_last_message().


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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号