Quick Filter:

How to Rename SQL DB even when it is in USE ?

 

Use this script to rename your db.

This one sets single user mod first so that there is exclusive access, then rename the db and bring back to normal mode (multi_user mode)

 

USE master;
GO

ALTER DATABASE [Old_DB_Name]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

ALTER DATABASE [Old_DB_Name]
MODIFY NAME=
[New_DB_Name]
GO

ALTER DATABASE [New_DB_Name]
SET MULTI_USER WITH ROLLBACK IMMEDIATE
GO

Baljeetsingh Sucharia

Baljeetsingh Sucharia

Founder & Chief AI Strategist at Sucharia Strategic Solutions. Ex-Microsoft Software Architect who constructs custom AI workflows and bespoke software for growing businesses.

README.md

Engineering & Leadership Logbook

Hey, welcome! I'm Baljeet.

This space is where I write down what I learn, build, and rethink while solving software and architectural challenges. Rather than keeping thoughts scattered across the web, I brought everything together into open streams:

๐Ÿ“ Personal Blog [2]
Long-form notes, code & design patterns
๐Ÿ’ผ LinkedIn Feed [3]
Field notes on tech & engineering leadership
๐ŸŸง Stack Overflow [4]
Hands-on solutions I've shared with developers

I love working fast with shortcuts, so I built this site to be browsed completely with your keyboard. Feel free to explore, filter what interests you, and make yourself at home!

Stream Switching
All Streams1
Blog Only2
LinkedIn Thoughts3
Stack Overflow4
Vim & Card Controls
Next CardJ / ↓
Prev CardK / ↑
Expand / Mini CardV / E
Toggle All Compact/FullX
Open SelectedEnter / O
Paging & Navigation
Older / Next PageN / >
Newer / Prev PageP / <
Prev / Next Article[ / ]
Scroll Top / BottomHome / End
Quick Tools
Trending ReadsT
README GuideR / M
Search TopicsS / /
Close / EscapeEsc
☕ Say hi, share feedback, or talk tech with Baljeet ↗