I have a problem with an application which uses the same stored procedure over and over again to populate people information in dropdown lists. The problem is that sometimes people aren't there anymore as the data changes. I have two views I can use to select from, but I want to dynamically change which view is being used based on the state of the application.
For new records, I only want to see current people. If I'm updating an existing record, I may want to see all people since the existing record may reference someone who is not current anymore.
How would I go about passing the view name in to my stored procedure so I can select from it?
I've already tried adding:
@view varchar(50)
select a, b from @view
But I get an error stating I must declare the variable @view.
Is this even possible to do?