Tried searching on this, but didn't get any hits.
Is there a way to list the databases that the current user has access to?
Back story. I was asked to create a script that runs some logic aginst all databases (used Name from Master.sysdatabases). However, they didn't really mean all databases as there are some on there that this data wouldn't need to come from and the logon they're using doesn't have access to. As such, the query craps out when it tries to hit a db in the list in can't access. The list is too long to build manually (plus it would need constant maintenance), so is there a way to get a list of dbs that the user executing the query has access to? Or at the very least check to see if it has access before trying to run the query and crap out?
Is there a way to list the databases that the current user has access to?
Back story. I was asked to create a script that runs some logic aginst all databases (used Name from Master.sysdatabases). However, they didn't really mean all databases as there are some on there that this data wouldn't need to come from and the logon they're using doesn't have access to. As such, the query craps out when it tries to hit a db in the list in can't access. The list is too long to build manually (plus it would need constant maintenance), so is there a way to get a list of dbs that the user executing the query has access to? Or at the very least check to see if it has access before trying to run the query and crap out?