2011-09-17 181 views
1

我最近更新了一个从2000版本到2005年的MSSQL服务器,以便利用UDF并调整系统中的某些结果。问题是我们没有源代码。SQL Server 2005中的TimeoutException从SQL Server 2000迁移

因此,我更换了SQL版本,并且每一次都正常工作,除非我们必须执行大型查询。我得到这个错误:

System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 

我搜索一下吧,和我所得到的是,它使用是一个CommandTimeout问题,我必须以编程方式解决,因为它应该是在客户端但这很奇怪,因为即使在大量查询的情况下,它也一直有效。

我的猜测是,这不是客户端,因为在SQL Server 2000工作正常。

有什么方法可以删除任何类型的超时?该系统是完全内部的,只有少数人使用它,所以没有中断风险......我更喜欢永久运行这个令人讨厌的消息的查询。

在此先感谢!

+0

所以,你利用的UDF和“微调”的服务器端代码,超越更改数据库的版本。您是否尝试回滚修复程序以尝试隔离它是版本问题还是您的“调整?” – billinkc

+0

超时由客户端设置,而不是由SQL Server设置,因此您不能从SQL Server端进行更改。 –

+0

@billinkc是的,同样的问题。 –

回答

0

您可以在连接上或者在设置连接时设置连接的超时时间。

SqlCommand1.CommandTimeout = 400000

+0

问题是我们没有源代码。 : - /但是,在客户端没有任何设置,因为当它连接到sql server 2000时,它确实有效。没有办法在服务器中设置默认值? –

+1

@Gonzalo - 如果你无法控制客户端的CommandTimeout值,那么我会建议分析应用程序正在调用的sql调用,并调整它们以缓解问题。 – etliens

+0

我记不起SQL 2005的头顶,但在2008年,您可以在管理工作室中右键单击服务器,转到属性,然后向下连接并设置远程查询超时。 –

1

您是否更新过升级后的所有统计数据?

How to: Upgrade to SQL Server 2005 (Setup)

After upgrading the Database Engine to SQL Server 2005, complete the following tasks:

...

Update statistics - To help optimize query performance, we recommend that you update statistics on all databases following upgrade. Use the sp_updatestats stored procedure to update statistics in user-defined tables in SQL Server 2005 databases.

Update usage counters - In earlier versions of SQL Server, the values for the table and index row counts and page counts can become incorrect. To correct any invalid row or page counts, we recommend that you run DBCC UPDATEUSAGE on all databases following upgrade.

+0

是的,我做到了。无论如何,问题不在于查询的时间。我需要像在SQL Server 2000中那样运行长查询。 –

+0

@Gonzalo - 我以为我会问,因为不好的统计数据肯定会导致升级后突然超时。 – etliens

相关问题