我可以强制SQL SMO使用READ UNCOMMITTED隔离? [英] Can I force SQL SMO to use READ UNCOMMITTED isolation?

查看:539
本文介绍了我可以强制SQL SMO使用READ UNCOMMITTED隔离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这是使用SQL2008 SMO抓住所有数据库的spaceAvailable属性的应用程序,但它往往成为其他进程长期持续时间阻止。我注意到,我可以运行它在SSMS与读取未提交的隔离任何问题产生的查询。

I have an application which is using SQL2008 SMO to grab the SpaceAvailable property of all of the databases, but it often becomes blocked by other processes for long a duration. I have noted that I can run the query it generates in SSMS with no issues in READ UNCOMMITTED isolation.

那么,做一个方式存在强制SQL SMO使用读未提交隔离?

So, do a way exist to force SQL SMO to use read uncommitted isolation?

推荐答案

对不起,迟到回复此。想我会的情况下,张贴此在有人需要帮助的未来。

Sorry for the late reply to this. Figured I'd post this in in case someone needs help in the future.

您可以设置指定的隔离级别当您创建Server实例。

You can set specify the isolation level when you create your Server instance.

请确保您有以下参考资料:

Make sure you have the following references:

using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.ConnectionInfo; 



然后创建连接

And then set the isolation level when creating the connection

Server theSQLServer = new Server(@"cb-z420vmsasq1\sql12");
        theSQLServer.ConnectionContext.SqlConnectionObject.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);

您可能要改变这种不同的交易。

You may have to change this for different transactions.

这篇关于我可以强制SQL SMO使用READ UNCOMMITTED隔离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆