I have a report created in SSRS which has a number of data sources.
On very rare occasions, one of those data sources may have been detached. This happened recently, as the SSAS Database was temporarily detached on the Dev server to free up memory for a large job.
When that happened, the entire report refused to run, throwing out the error "Query Execution failed for dataset 'DatasetName' (rsErrorExecutingCommand) Either the user, 'UserName', does not have access to the 'DBName' database, or the database does not exist.
Is there anyway to amend either the dataset, or perhaps the query in the datasource, so that if the query fails (because the DB is down / detached) that it still runs everything else, but perhaps shows an error on the report.
[EDIT]
With assistance from Bushell - this is what I ended up using:
1) On the SQL Server (which should always be up) - I created a Linked Server to the SSAS instance
2) Changed my Datasource in SSRS to point to the SQL Server instead of the SSAS instance
3) Used this query (see below) to check whether the SSAS linked server was up - I haven't been able to test with SSAS down, but it does work while it's up! (if anyone reading this is using the same method, you'd just have to replace my 'Select Distinct ... etc.' with your own query)
BEGIN TRY
EXEC sp_testlinkedserver N'SSAS_LinkedServer';
EXEC sp_executesql N'SELECT * FROM OPENQUERY(SSAS_LinkedServer,
''SELECT
DISTINCT
[CATALOG_NAME] as [Database],
[CUBE_NAME],
DIMENSION_CAPTION AS [Dimension],
DIMENSION_CARDINALITY AS [Count]
FROM $system.MDSchema_Dimensions
ORDER BY DIMENSION_CARDINALITY DESC;'');';
END TRY
BEGIN CATCH
SELECT
'' as [Database],
'' as [CUBE_NAME],
'' AS [Dimension],
'' AS [Count]
END CATCH
Thanks to Bushell for pointing me in the right direction.