Seggerman-675349 (4/17/2008)
I am not sure of the feasibility of this but I would recommend writing your program to use a synonym for the table name - then use dynamic sql to create the synonym from whatever the table name is. Then DROP the synonym at the end. That way the logic of the stored procedure is static and only the synonym creation is dynamic.
And if two instances of the same proc run at the same time, what then? 😉
And, yeah... I realize the post is more than 3 years old but since this thread has been reactivated, I wanted to make sure folks knew this is likely a bad idea.
--Jeff Moden
Change is inevitable... Change for the better is not.