1

Normally to see all the databases in a SQL Server, you can use:

IF (EXISTS (SELECT name 
            FROM master.dbo.databases 
            WHERE 'myDB' = @dbname 
               OR name = @dbname)))

previous post

But in AWS RDS, I get this error:

Invalid object name 'master.dbo.databases'

Is there another place to look up the databases in AWS RDS? By default there is always rdsadmin and then anything else the user adds.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Lacrosse343
  • 491
  • 1
  • 3
  • 18
  • Interesting that that's the accepted answer, because `master.dbo.databases` will not work on any installation of SQL Server -- not any recent version, at least. `sys.databases` is another matter. – Jeroen Mostert Nov 02 '22 at 16:19
  • I seems like `master.sys.sysdatabases` is what I am looking for. Is that what you mean? – Lacrosse343 Nov 02 '22 at 17:01
  • Technically it's unnecessary to add `master`; there's only one `sys.databases` and its contents will not change by adding a database (nor is any database capable of declaring its own `sys.databases`). I also don't know if an RDS-hosted server works the same as an on-premise server -- all I know is that `master.dbo.databases` is right out. – Jeroen Mostert Nov 02 '22 at 17:08

0 Answers0