I have a view with 3 unions combining datasets from 4 different databases. It works fine if the user has access to all 4, but it does fail if a user doesn't have access to any one of the databases queried. Is there a way to have the query return the data from only the databases they have access to without failing?
Something like this:
IF USERACCESS TO DB1 = TRUE
(SELECT A,B,C
FROM DB1..TABLE1
UNION ALL
)
IF USERACCESS TO DB2 = TRUE
(SELECT A,B,C
FROM DB2..TABLE1
UNION ALL
)
IF USERACCESS TO DB3 = TRUE
(SELECT A,B,C
FROM DB3..TABLE1
)