I have a stored procedure that looks something like this:<br><br>CREATE PROCEDURE sp_dosomething @param1 varchar(5) AS<br> if @param1 = "this"<br> select * from database1.dbo.table1<br> else if @param2 = "that"<br> select * from database2.dbo.table1<br> else<br> select * from database3.dbo.table1<br><br>Each of my users generally has access to only one of the databases (database1, database2, or database3), although some have access to more than one. The problem is that when a user who has access to less than all the databases referenced in the sproc tries to run the sproc (with a parameter of "this"
, he gets an error about not having permission on database2, even though the line the referenced database2 was not going to be called. It's sort of like the stored procedure is "early binding" all the tables it could <i>possibly</i> use, when what I want it to do is "late bind" only the tables that are <i>actually</i> used. Does all that make any sense? It seems like there must be some way to do this. Anyone?