TSQL Execute result different in PHP and SSManagement Studio
I’m querying a MSSQL Procedure from PHP and SSManagement Studio and the result is different??
This query is getting the fields starting by tKey from the table. Two columns tKey1 and tKey2 exists
DECLARE @tKeys VARCHAR(100); SELECT @tKeys = ISNULL(@tKeys + ',', '') + column_name FROM testweberp.INFORMATION_SCHEMA.columns WHERE table_name = myTable AND LEFT(column_name, 4) = 'tKey' ORDER BY ordinal_position; SELECT @tKeys
When I execute the query from SSMS, exec sp_myProc, i get the result:
When I execute the query from php,
mssql_query("exec sp_myProc",$link), I get the result:
Yes, there is an extra comma in the result sent to php
And it is not produced by php, because if instead of
@tKeys, I return the
len(@tKeys), it is
11 in SSMS and
12 in php?
One Solution collect form web for “TSQL Execute result different in PHP and SSManagement Studio”
It seems SET CONCAT_NULL_YIELDS_NULL may be the culprit.
Using a similar query on one of my databases returns no leading comma for
SET CONCAT_NULL_YIELDS_NULL ON, and a leading comma for
SET CONCAT_NULL_YIELDS_NULL OFF.
Note that (from MSDN)
The setting of SET CONCAT_NULL_YIELDS_NULL is set at execute or run time and not at parse time.