Reputation: 1934
I've got several stored procedures (worker procs) which will be queried by a main stored proc called Calc
. Calc
creates a synonym called S
of a table, which name is passed by a parameter.
The worker procs work with the synonym table.
Works for admin login.
Problem: If a user executes Calc
the synonym will be Domain/Username.S
and the worker which access S
doesn't find Domain/username.S
If the admin created the synonym it is called dbo.S
and workers work by only accessing S
.
How can the worker stored procs access the synonym created by the user which called Calc
?
So that X users can call Calc
and operate on different tables S
but use the same worker procs.
Thank you in advance, hopefully somebody can help me.
Environment: SQL Server 2008 Granted User Rights: Create Synonym
Upvotes: 0
Views: 667
Reputation: 280350
Use the schema prefix when creating calc, executing calc, creating S, and calling S. Or make sure that all of your users have access to the same default schema. But I prefer the former.
Upvotes: 1