下午好, 我有我的代码的以下模拟脚本。似乎以下内容不适用于PHP并且不返回任何错误,但查询将发送到SQL Server,我可以在分析器跟踪中看到它。 PHP返回无响应。
想法?
可以使用PHP:
SELECT * FROM TABLE
无法使用PHP:
DROP TABLE #TMP1
SELECT 50 AS INT INTO #TMP1
SELECT * FROM #TMP1
无法使用PHP:
DECLARE @TABLE TABLE
(
ID INT
)
INSERT INTO @TABLE (ID)
SELECT 40
SELECT * FROM @TABLE
无法使用PHP:
<?php
$databaseName = "DB" ;
$serverName = "3424.34.234.3";
$uid = "sdfsf";
$pwd = "Jsdfsf";
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd ,
"Database"=>$databaseName);
/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $serverName , $connectionInfo);
$tsql = "
DECLARE @TABLE TABLE
(
ID INT
)
INSERT INTO @TABLE (ID)
SELECT 40
SELECT * FROM @TABLE
";
//EXEC PLAYER_LOOKUP '$result';
/* Execute the query. */
$stmt = sqlsrv_query( $conn, $tsql);
//Working Query
/* Iterate through the result set printing a row of data upon each iteration. BR=."\n" */
while($row = sqlsrv_fetch_ARRAY($stmt, SQLSRV_FETCH_ASSOC)){
{
echo $row;
}}
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>
答案 0 :(得分:0)
您所要做的就是在存储过程开始时调用SET NOCOUNT ON。这样可以防止&#34;行受影响&#34;要发送到客户端的消息,并将其误认为是过程的输出。您也可以在SELECT * INTO语句之前设置它。