在数据库级别设置 NOCOUNT OFF?
我可以将特定数据库的 NOCOUNT 默认设置为 OFF 吗?
我需要它用于 NHibernate(如果它打开,我在保存时会遇到异常)。我可以看到为整个服务器禁用它的设置(它被设置为ON),但我们正在与其他数据库共享该服务器。有没有办法只为我的数据库将其设置为“关闭”?
或者是否有 NHibernate 设置可以为我完成此操作? (我现在已经使用自定义的 DriverConnectionProvider 来解决这个问题,每当创建连接时都会发出命令。工作正常,但感觉有点尴尬)
顺便说一句,我正在使用 SQL Server 2000。
谢谢 马特
Can I set NOCOUNT to be OFF by default for a particular database?
I need it for NHibernate (if it's ON, I get exceptions when saving). I can see the setting to disable it for an entire server (where it's set ON), but we're sharing the server with other databases. Is there a way I can set it to OFF just for my database?
Or is there an NHibernate setting that will do this for me? (I've worked around it for now with a custom DriverConnectionProvider that issues the command whenever it creates a connection. Works ok, but feels a bit awkward)
I'm using SQL Server 2000, btw.
Thanks
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不,
SET NOCOUNT
没有数据库范围的设置。同样的问题: http://www.eggheadcafe.com/software/aspnet /32120672/set-nocount.aspx
no, there is no database wide setting for
SET NOCOUNT
.same question: http://www.eggheadcafe.com/software/aspnet/32120672/set-nocount.aspx
您可以使用 NH
IInterceptor
接口的OnPrepareStatement
方法来修改 NH 生成的 SQL 语句,以在您发出的每个 sql 查询的顶部包含一个“set nocount off”语句。应用。一些叫 Dave 的家伙认为这是“邪恶的” “这样做,但这可能是你的答案。该链接会将您带到他的博客上描述如何实现它的页面。
我对此的保留意见是,您将创建对运行在理解“set nocount off”的数据库服务器上的应用程序的依赖关系 - 换句话说,您将忽略配置的方言。
You could use the NH
IInterceptor
interface'sOnPrepareStatement
method to modify the NH-generated SQL statements to include a "set nocount off" statement at the top of every sql query issued by your application.Some bloke called Dave reckons it's "evil" to do so, but it might be your answer. The link takes you to the page on his blog describing how to implement it.
My reservation about doing so is you would be creating a dependency on your application running against a database server that understands "set nocount off" - in other words, you'd be ignoring the configured dialect.
您也可以从 SSMS 设置数据库的 nocount 属性 ON/OFF。请在下面找到
You can set nocount property of database ON/OFF from SSMS as well. Please find below
设置 NOCOUNT 是在数据库级别设置的。分别依次执行以下查询。这提供了更好的想法。
Set NOCOUNT is Set at DB level. Execute below queries one after another separately. This gives better idea.