select * from sys.databases (or select * from sysdatabases)
My question is how can we know that which db is system database and which one is user created?
Regards
Karan Gupta
Microsoft SQL Server 2008Microsoft SQL Server 2005Microsoft SQL Server
Last Comment
YZlat
8/22/2022 - Mon
Barry Cunney
-- User Databases
Select *
From sys.databases
Where database_id > 5
--System Databases
Select *
From sys.databases
Where database_id <= 5
KaranGupta
ASKER
is 1-4 id fixed for system dbs in all versions of sql server. What is the role of sid field
YZlat
SID is a system-level identification number.
when an object is created it is assigned an id - SID, that number identifies the object as a securable within SQL Server and then the object is deleted, the id is recycled.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
Select *
From sys.databases
Where database_id > 5
--System Databases
Select *
From sys.databases
Where database_id <= 5