With two databases A and B on the same SQL Server 2014 instance, I've written a series of scripts trying to do the following (written in very high level pseudo code):
User Updates table
A.dbo.MainA.dbo.Mainhas a trigger onUPDATE, DELETE, INSERTthat calls a stored procedureA.CallProcInBA.CallProcInBthen calls a stored Procedure in B calledB.RunComponentsUpdateB.RunComponentsUpdatethen merges a view and a table calledB.dbo.A_ViewandB.dbo.B_Table.
The problem is I have gotten these series of scripts to work perfectly on a personal computer running SQL Server 2014 Express, with the exact same schema setup for the databases A and B, but when I set everything up on my company's main server running SQL Server 2014 I get the following error message:
System.Data.Odbc.OdbcException (0x80131937):
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]
The SELECT permission was denied on the object 'B_Table', database 'B', schema 'dbo'. ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]
The UPDATE permission was denied on the object 'B_Table', database 'B', schema 'dbo'.
I've tried giving the user activating the initial trigger all privileges on both A and B, as this was enough to fix the issue on my personal computer server. However, giving basically "god" privileges hasn't been enough to resolve this error on the server.
EXECUTE ASanywhere. And the reason it works locally for you is that you are running assaor your Windows Login is in the Administrators group which is usually given the server-level role ofsysadmin. But if you are using theEXECUTE ASclause in theA.CalProcInBproc, that will prevent this from working. – Solomon Rutzky Mar 07 '17 at 19:17-Created certificate in A
-Created TempTable in A
-Used Cert and Table in A to create Cert in B
-edited both stored procedures on A and B to include "SET NOCOUNT ON" before executing rest of scripts
-Used ADD SIGNATURE on both stored pocedures
-ran code
still got the error :/
– ErickM Mar 07 '17 at 19:27deny). – Solomon Rutzky Mar 07 '17 at 20:26