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

  • OR statement isn't working
  • How to detect numbers in string in many observations?
  • How can I use single query to insert multiple records from Dataset into SQL Server 2005?
  • How do I create a list of 5 number permutations based on a list of numbers ranging from 1-69?
  • Creating stored procedure in another database
  • Script that provides the row counts and table names
  • 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?

  • Current transaction ID in an audit trigger
  • Getting an odd error, SQL Server query using `WITH` clause
  • SQL Server : can you limit access to only one table
  • How to Ignore “Duplicate Key” error in T-SQL (SQL Server)
  • How to generate temp table columns and datatypes automatically via script
  • SQL Server version 612 , 655?
  • 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.