How can I specify that my app should start SQL Server LocalDb with a trace flag parameter?

霸气de小男生 提交于 2019-11-29 04:35:40
Richard Moore

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.

Stop the LocalDB process by running SQLLOCALDB.EXE in a command prompt, passing in stop as a parameter and the name of the instance. For example:

C:\> sqllocaldb stop mssqllocaldb

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. For example:

C:\>sqlcmd -S (LocalDB)\MSSQLLocalDB -Q "DBCC TRACESTATUS();"

To test this I've been using VS2015 server explorer to explore the database. Killing the LocalDB process in Task Manager (sqlservr.exe), 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!