普通网友
2016-02-16 11:13
浏览 60
已采纳

从php调用时,SQL Server存储过程中止

I have spent hours trying to get to the bottom of this and it is driving me la la.

I have a simple stored procedure that just inputs 10,000 rows into a table. This is done because it takes long enough to prove the point (about 12 seconds).

create table lala (id int not null identity(1,1), txt varchar(100))
go
CREATE PROCEDURE lalatest
AS
BEGIN
    DECLARE @x int;
    SET @x = 10000;
    WHILE @x > 0
    BEGIN
        INSERT INTO lala (txt) VALUES ('blah ' + CAST(@x AS varchar(10)));
        SET @x = @x - 1;
    END;
END;

When I run the stored procedure from within SQL Server Management Studio, 10,000 rows are inserted into the table.

When I run it from php it just aborts after about 150 rows (the number of rows varies, suggesting a timeout issue) with no error messages or any indication that it has finished early

The remote query timeout setting is set to the default of 600 seconds, so its not that.

The php:

$sql = "exec lalatest";
sqlsrv_query($cn, $sql);

I have tried specifying a timeout value (which should be indefinite by default anyway) on the sqlsrv_query line and it made no difference.

I'm using php 5.6.7

and Microsoft SQL Server 2012 (SP3) (KB3072779) - 11.0.6020.0 (X64) Oct 20 2015 15:36:27 Standard Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)

I have all errors and warnings turned on

Anyone got any ideas as to what I need to do to make this work?

图片转代码服务由CSDN问答提供 功能建议

我花了好几个小时试图找到它的底部并且它驱使我拉啦。

我有一个简单的存储过程,只需在表中输入10,000行。 这样做是因为它需要足够长的时间来证明这一点(大约12秒)。

  create table lala(id int not null identity(1,1),txt varchar(  100))
 
 
 
 
 
 
CREATE PROCEDURE lalatest 
AS 
BEGIN 
 DECLARE @x int; 
 SET @x = 10000; 
 WHILE @x>  0 
 BEGIN 
 INSERT INTO lala(txt)VALUES('blah'+ CAST(@x AS varchar(10))); 
 SET @x = @x  -  1; 
 END; 
END; 
    
 
 

当我从SQL Server Management Studio中运行存储过程时,会在表中插入10,000行。

当我运行时 它来自php它只是在大约150行之后中止(行数变化,提示超时问题)没有错误消息或任何早期完成的迹象

remote 查询超时设置默认设置为600秒,所以不是这样。

php:

  $  sql =“exec lalatest”; 
sqlsrv_query($ cn,$ sql); 
   
 
 

我已经尝试指定超时值(默认情况下应默认为无限期) 在sqlsrv_query行上并没有什么区别。

我正在使用php 5.6.7

和Microsoft SQL Server 2012(SP3)(KB3072779) ) - 11.0.6020.0(X64) 2015年10月20日15:36:27 Windows NT 6上的标准版(64位) .1(Build 7601:Service Pack 1)(管理程序)

我打开了所有错误和警告

任何人都对什么有任何想法 我需要做的才能使这个工作?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题