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

  • TSQL query to find un-used stored procedures
  • Null instead of integer foreign key performance and space considerations
  • Data mixing SQL Server
  • SQL Server stored procedure avoid cursor
  • how to debug a recursive trigger
  • How to check something before a /
  • Procedure sp_myProc

    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: tKey1,tKey2

    When I execute the query from php, mssql_query("exec sp_myProc",$link), I get the result: ,tKey1,tKey2

    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?

  • ASP.NET Entity Framework 6 HashSet or List for a collection?
  • Add column and update it within a transaction
  • How to read three columns of a SQL Server table with SqlDataReader and store values in double array
  • Finding a geography point within a range of another - SQL Server
  • SQL server wrong Row Number is showing
  • Is it possible to password protect an SQL server database?
  • 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.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.