Get number total User counts for each DB within SQL Server instance ?

techresearch7777777 1,801 Reputation points

Hello, can someone provide me a query to list all User DBs (not including master, model, msdb, tempd) within a SQL Server instance and their number of Total Users counts (not including system dbo, guest, INFORMATION SCHEMA, sys) that has access to each DB?

Output would be something like this:

[Database Name] [Total Users]

Products = 3

Sales = 7

Invoices = 11


Am thinking GROUP BY would be used along those lines.

Thanks in advance.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,122 questions
{count} votes