如何指定我的应用程序应该启动具有跟踪标志参数的SQL Server LocalDb? [英] How can I specify that my app should start SQL Server LocalDb with a trace flag parameter?

查看:143
本文介绍了如何指定我的应用程序应该启动具有跟踪标志参数的SQL Server LocalDb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用LocalDb实例来存储它的数据。我注意到了一个奇怪的方式,LocalDb已经分配了识别(解释更多的这里),我想避免。链接的答案解释说,这可以通过设置SQL Server跟踪标志来完成,并解释如何为全脂肪SQL Server执行此操作。



是否可以在LocalDb上设置跟踪标志?当我的应用程序按需启动时,可以通过连接字符串来完成吗?

解决方案

我有一个类似的问题,相信我有一个解决方法...



启动Regedit并找到您的localdb注册表项。对我来说,这是

  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL12E.LOCALDB\MSSQLServer\ 

在此键内创建另一个名为参数的键。



在参数键内创建一个名为 SQLArg0 的字符串(REG_SZ),并将其值设置为 -t272 。 / p>

杀死SQLLocaldb进程(我通过将其终止在任务管理器中,因为它不显示为Windows服务)。然后使localdb通过连接到数据库自动启动。



运行查询 DBCC TRACESTATUS(),您应该会看到跟踪标志272存在。



要测试这个,我一直在使用VS2015服务器资源管理器来探索数据库。杀死localdb进程,连接到VS2015中的数据库并手动添加一个新的行将使我的自动增量值跳转1000。添加上述注册表黑客之后,手动终止localdb进程不会导致下一个生成的身份值跳过。



HTH


My application uses a LocalDb instance to store it's data. I've noticed a quirk in the way that LocalDb has allocated identifies (explained more here) which I'd like to avoid. The linked answer explains that this can be done by setting an SQL Server trace flag, and explains how to do this for "full fat" SQL Server.

Is it possible to set a trace flag on LocalDb? As my application starts it on demand, could this be done through the connection string?

解决方案

I have a similar problem and believe I have a workaround...

Launch Regedit and find your localdb registry key. For me this was

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL12E.LOCALDB\MSSQLServer\

Within this key create another key named Parameters.

Within the Parameters key create a string (REG_SZ) named SQLArg0 and set its value to -t272.

Kill the SQLLocaldb process (I did this by terminating it in task manager as it doesn't show as a Windows service). And then cause localdb to auto start by connecting to a database on it.

Run the query DBCC TRACESTATUS() and you should see that the trace flag 272 is present.

To test this I've been using VS2015 server explorer to explore the database. Killing the localdb process, connecting to the database in VS2015 and adding a new row manually causes my auto-increment value to jump by 1000. After adding the registry hack described above, manually terminating the localdb process doesn't cause the next generated identity value to skip.

HTH

这篇关于如何指定我的应用程序应该启动具有跟踪标志参数的SQL Server LocalDb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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