English 中文(简体)
从 Web 执行程序创建的记录少于 SQL 管理工作室运行的记录
原标题:Executing procedure from web create less records than running from SQL Management Studio

MS SQL 我有一个程序 CM_ Export 将记录插入表格。 当我直接从 SQL 管理工作室( < code> EXEC dbo. CM_Export DB1, DB2, 1 ) 运行时, 它插入了 80 行。 但是当我从网络运行时, 它只插入 20 行。 在两种情况下, 它都需要一秒。 在网络中, 我尝试了两种方式 :

(1)(1)

    $sql = "EXEC dbo.CM_Export  DB1 ,  DB2 , 1";
sqlsrv_query($conn, $sql);

2) 2)

  $tsql = "{call CM_Export(?, ?, ?)}";

$params = array(array("DB1", SQLSRV_PARAM_IN),
 array("DB2", SQLSRV_PARAM_IN),
 array(1, SQLSRV_PARAM_IN)
);

$stmt = sqlsrv_prepare($conn, $tsql, $params);    
if($stmt) {    
 echo "Statement prepared.
";    
} else {    
 echo "Error in preparing statement.
";    
 die( print_r( sqlsrv_errors(), true));    
}    

if(sqlsrv_execute($stmt)) {    
 echo "Statement executed.
";
} else {
 echo "Error in executing statement.
";
 die(print_r(sqlsrv_errors(), true));
}
sqlsrv_free_stmt($stmt);

没有错误 。 我尝试在剖析器中捕捉什么运行, 当我把它复制到管理工作室时, 程序会插入80行, 从 Web 插入 20 插入 80 行 。 当我添加到存储程序 TRANSLATO 时, 所以从 Web 中运行不会添加行 。 但是没有错误 - 从管理工作室运行是确定 。 我还尝试追踪, 并且有 :

Exit SQLExecDirectW 具有返回代码 0 (SQL_ SSCOSS)

当我做多次刷新时( Ctrl + R, 不在程序中 TRANSLATORS 中), 所以从前 20 行程序 中添加其他行, 我就可以创建大约 40 行。 所以问题似乎在某个超时中。 但是在脚本中添加超时参数没有效果 。

sqlsrv_query($conn, $sql, array(), array( QueryTimeout  => 100))

在追踪记录中,我还发现:

WWHAR * 0x50418B34 [-3]

使用 SQL的 ODBC 驱动程序有问题。 我使用 SQL 2008 R2 64b。

问题回答

所以我找到了解决方案 - < a href=""http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/e0908b2f-4afa-4626-830d-9683486186c8" rel="nofollow" > 添加SET NOCOUNT 以存储程序 !

您是否尝试删除 sqlsrv_free_stmt? 声明可能在工作完成前被解开 。

当脚本执行完成时, 语句仍应该被清除 。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签