Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Stop a query if cross database queries are requested in the command?

$
0
0

Hi,

is there a way to raise an error if a user run a SELECT statement which contains specific keywords?

here my scenario:

I want to insure that if a user open a connection to a specific database and try to execute a select statement which  access another specific database, then raise an error.

example:

connection to the DB1 database, query= Select * from DB2.dbo.Table, then raise an error

connection to the DB1 database, query= Select * from DB3.dbo.Table, then NO error (this DB3 access from DB1 is permitted)

The user has access to the DB1 and the DB2 databases, I want to insure that 2 databases are never used in cross database queries.

is it possible to filter this in SQL Server? (using database triggers, server triggers or session event?)

thanks.


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>