info@techdevops.com | 437-991-3573 | Data Engineering Services
TechDevOps.com
Resources Tools
Experts in Microsoft SQL Server on Windows, Linux, Containers | Clusters, Always On, FCI | Migrations, Cloud, Performance



T-SQL - List Databases, Logins & SQL Jobs
by BF (Principal Consultant; Architecture; Engineering)
2018-05-14








T-SQL:


Select
@@SERVERNAME as 'Server',
[name] as 'Database',
database_id as 'DBID',
lower(suser_sname([owner_sid])) as 'Owner',
recovery_model_desc,
state_desc,
user_access_desc,
is_read_only,
log_reuse_wait_Desc,
[compatibility_level],
create_date,
collation_name,
is_query_store_on,
is_published,
is_distributor,
is_encrypted,
target_recovery_time_in_seconds,
delayed_durability_desc,
is_mixed_page_allocation_on,
replica_id,
is_auto_create_stats_on,
is_auto_update_stats_on
from master.sys.databases

Select
[Name],
[Type_Desc],
default_database_name,
[sid],
is_disabled,
create_date,
modify_date
from master.sys.server_principals
order by [Type_Desc] desc

Select
lower(@@SERVERNAME) as 'Server',
[name] 'Job Name',
lower(suser_sname([owner_sid])) as 'Job Owner',
[enabled],
date_created,
date_modified
from msdb.dbo.sysjobs