I try to explain correctly: I have stored procedures that use two tables: myFiles and myBooks. Now I want to create two new tables myFilesProduction and myBooksProduction.
What's the best way to change stored procedures to select the correct tables to use with an argument ?
Use a variable
@nameTablewith dynamic queries?IF(@isProduction) SET @books = 'myBooksProduction' EXEC 'SELECT * FROM' + @booksBut I already use dynamic SQL in some procedures.
Using a simple condition
IF(@isProduction) BEGIN -- SELECT * FROM MyFilesProduction, MyBooksProduction ELSE -- SELECT * FROM myFiles, myBooks ENDbut I have to use redundant code
some other way ?