We are developing an application where sometime we need to support more than one versions of that software at a time. For example Release 1-0-300 , 1-0-300-With-Test-FunctionalityA, Release 1-0-300-With-Test-FunctionalityB. Due to such requirements we sometime use the same Stored Procedure with different name in different versions for example
“1-0-300” uses Stored Procedures “USP_GetProucts“
“1-0-300-With-Test-FunctionalityA” uses Stored Procedures “USP_GetProucts_FunctionalityA“
“1-0-300-With-Test-FunctionalityB” uses Stored Procedures “USP_GetProucts_FunctionalityB“
Some Facts:
1- Why we are not using some alternate solution like we can have a Parameter “WhichStoredProcedureToCall” based on that parameter we can call the required STored Procedure?
Because “USP_GetProucts” can have total different functionality than “USP_GetProucts_FunctionalityA” & these are huge stored procedures.
2- We are using SQL2008.
So my question is can we implement some type of “Stored Procedure Redirect“, if “USP_GetProucts_FunctionalityA” not found then get the results form “USP_GetProucts”
Regards.
You can see if a
stored procedureexists acessing to thesysobjects table:Then you simply need to make the necessary
IF‘s.Since you are using
SQL Server, you could have a look intoSINONYMS.You could make
USP_GetProucts,USP_GetProucts_FunctionalityAandUSP_GetProucts_FunctionalityBsinomyns 🙂