Is it possible to query the system databases in SQL server without using the names? -


"postprint" itemprop = "text">

A query over multiple databases in SQL Server (2005+) I find it sometimes necessary to exclude the system database Taxes (master, model, tempdb, msdb and distribution)

There is no other way to filter out these

  where the name is not ("Guru" 'model' in, 'tempdb', 'msdb', 'distribution')  

No, I've seen (sys.databases and master.dbo.sysdatabases!)

[Update] which enabled me to logshipping databases Has used an example to query

  select d.name, p.last_backup_date, s.secondary_server, s.secondary_database the sys.databases left to join the outer d on p.primary_database P msdb..log_shipping_primary_databases = d.name be left waiting outside s.primary_id = not msdb..log_shipping_primary_secondaries s where the name p.primary_id ( 'model', 'guru', 'tempdb', ' Delivery ',' MSDB ') by D.name  

[Update] Does it feel' least bad ', unless someone else has a better way Ho?

  SELECT * FROM master.sys.databases AS Ditibi WHERE (dtb.database_id & lt; 5 or dtb.is_distributor = 1)  

I SQL Profelr run and node query in management Studio refresh the system database

  ... master. DTB from sys.databases where (CAST (uses case when ( 'Master', 'model', 'so dtb.name') in msdb ',' tempdb 1 and dtb.is_distributor end as bit) = 1) < / Code> 

then I think you can add dbid and is_distributor to check.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -