Jack Ukleja
Jack Ukleja

Reputation: 13521

How to delete SQL Local Db instance if user owner has been deleted?

I have a strange situation where a user on this workstation was deleted, but they owned a shared localdb. I now need to clean up this mess as this shared database is used by an automated system test, but I can't delete it.

If I do sqllocaldb i TheDatabase I get something similar to:

Invalid SID or account name (domain\account): "S-1-12-1-3936653584-1214288953-3252656789-1065815451".
Name:               TheDatabase
Shared name:        TheDatabase
Owner:              S-1-12-1-3936653584-1214288953-3252656789-1065815451
Instance pipe name: np:\\.\pipe\LOCALDB#SH77646D\tsql\query

If I try to delete this database I get:

Delete of LocalDB instance ".\TheDatabase" failed because of the following error:
API caller is not LocalDB instance owner. 

How can I resolve this?

Upvotes: 1

Views: 1553

Answers (1)

Jack Ukleja
Jack Ukleja

Reputation: 13521

When running as an admin it seems I was able to unshare it with:

sqllocaldb u .\TheDatabase

From there I was able to delete it.

Upvotes: 3

Related Questions