Skip to content

Daniel Hillebrand

Tech and stuff, mostly .NET and web related.

  • Tools
  • About
  • Contact
  • Privacy Policy

Recent Posts

  • VirtualBox CPU Performance Tuning
  • Rename an SQL Server Database that could not be exclusively locked
  • Developer and Power User Tools for Windows
  • Notes about Live Unit Testing in Visual Studio
  • Breakpoint in ASP.NET MVC View not hit when using RazorGenerator

Recent Comments

  • Daniel on How to reset a SQL Server LocalDB instance in Visual Studio
  • Alex on How to reset a SQL Server LocalDB instance in Visual Studio
  • Daniel on “Inconclusive” error in ReSharper unit test runner caused by “async void”
  • Michael Freidgeim on “Inconclusive” error in ReSharper unit test runner caused by “async void”
  • ASP.NET MVC Identity whitelisting vs blacklisting – Don’t trust yourself – Daniel Hillebrand on Enable global authentication with ASP.NET MVC and Identity

Archives

  • July 2019
  • June 2018
  • November 2017
  • September 2017
  • August 2017
  • July 2017

Categories

  • ASP.NET
  • ASP.NET Identity
  • Azure
  • blogging
  • C#
  • Debug
  • DotNet
  • Ergonomy
  • MVC
  • Performance
  • Security
  • SQL
  • SQL Server
  • Testing
  • Tools
  • Visual Studio
  • web development

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Category: SQL

Rename an SQL Server Database that could not be exclusively locked

Quick note about how to rename an SQL Server database that could not be exclusively locked (because it has open connections to it):

ALTER DATABASE currentDbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
EXEC sp_renamedb N'currentDbName', N'newDbName';
GO
ALTER DATABASE newDbName SET MULTI_USER WITH ROLLBACK IMMEDIATE;
GO

 

Posted on July 23, 2019Categories SQL, SQL Server
Privacy Policy Proudly powered by WordPress