I have to premit that i am not a DBA but i have the need to mantain a SQL Server instance and have few problem with stored procedure permission chaining (hope terms is correct).
To brifiley explain my needs, i have an user that should have grant only on one DB that should run a stored procedure (on that "granted" DB) that contain reference to an external DB (i should inherit somewhat grant)
In details, my scenario is that i have three DBs
- Configuration DB (should be read by everyone but never written by no-one except Configuration User)
- Staging DB (should be read/written by staging procedure)
- Final DB (should be read/written by app)
So i have three users
- Configuration User : used to mantain data in Configuration DB
- Staging User : used by many staging procedure (very long procedures, may take hours) that place data into the Staging DB
- Final User : used by the application that read the data when staging procedure finished to deploy data in Staging DB and put it back Final DB. Final User can access every DB (at least for reading)
So far so good, staging procedure do their work and when complete write a semaphore (to notify data are ready). Sometimes the application (that use Final User) check the semaphore and ingest all the data into the Final DB.
Now i have to support a fast, on-demand staging procedure (i still need to execute in from Staging DB for other reasons) that when completed, should update directly the data into Final DB.
I have writte such procedure and everything work as intended, but i have to grant read/write operation on FinalDB to Staging User and i don't like it. There are many application that use Staging User and some of them is not "under my control", so i don't wont that a faulty application that should write data into Staging DB will end up messing with Final DB. I can accept that my new on-demand staging procedure may be critical (and end up messing with Final DB).
So the question is, Staging User is already granted to execute a stored procedure (EG : OnDemandUpdate) because it is part of Staging DB but that contain insert/update over an external table (from Final DB) and i want that the grant can be chained. How can i do that?