question

yaqubonnet avatar image
yaqubonnet asked

Stored Procedure Redirect logic

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.
sql-server-2008sqlstored-procedures
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Grant Fritchey avatar image
Grant Fritchey answered
You could do that directly from your code pretty easily. But, you could build a wrapper procedure that calls other procedures. That's a pretty standard coding methodology. It's also easy to check the row count within a proc to determine if the previous call returned anything (or even return an output parameter that says no results were forthcoming) and then call another proc. You have choices.
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

+1 : definitely from code, especially if 2 similarly named procs "can have total different functionality"
1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.