dependent, see
It really depends on what would take place inside the IF branch, which you've conveniently omitted any details about. There are of course potential concerns about compilation time, plan complexity, and other things. The main problem you may find yourself dealing with is plan quality because of parameter usage and cardinality estimation.
when it wouldn't matter
Let's say you have a stored procedure with one parameter used as a search predicate, and two IF branches that both use that parameter.
CREATE OR ALTER PROCEDURE
dbo.TwoBranches
(
@DisplayName nvarchar(40),
@WhichWay bit = 0
)
AS
BEGIN
IF @WhichWay = 0
BEGIN
SELECT
c = COUNT_BIG(*)
FROM dbo.Users AS u
WHERE u.DisplayName = @DisplayName;
END;
IF @WhichWay = 1
BEGIN
SELECT
c = COUNT_BIG(*)
FROM dbo.Users AS u
JOIN dbo.Posts AS p
ON p.OwnerUserId = u.Id
WHERE u.DisplayName = @DisplayName;
END;
END;
When SQL Server compiles this stored procedure, both queries will have an execution plan generated, even though only one IF branch will be executed at runtime. This includes cardinality estimation for both queries, based on the compile-time value for the @DisplayName parameter.
The reason why this is okay here is that both branches make use of it. Whether parameter sensitivity is an issue or not is somewhat irrelevant, though always worth keeping in mind.
Let's look at a different situation!
when it would matter
For this stored procedure, we have two branches, and each branch makes use of a different search parameter.
CREATE OR ALTER PROCEDURE
dbo.TwoBranches
(
@Reputation integer = NULL,
@Score integer = NULL,
@WhichWay bit = 0
)
AS
BEGIN
IF @WhichWay = 0
BEGIN
SELECT
c = COUNT_BIG(*)
FROM dbo.Users AS u
JOIN dbo.Posts AS p
ON p.OwnerUserId = u.Id
WHERE u.Reputation = @Reputation
END;
IF @WhichWay = 1
BEGIN
SELECT
c = COUNT_BIG(*)
FROM dbo.Users AS u
JOIN dbo.Posts AS p
ON p.OwnerUserId = u.Id
WHERE p.Score = @Score
END;
END;
Now when the stored procedure is compiled, one search parameter will likely be NULL, or a canary value like 0. One plan will get cardinality estimation based on the "real" search parameter value, let's say @Reputation = 1000, and @Score will get cardinality estimation based on NULL or the canary value. This could very well be a disaster.
you're probably right
Putting the branched code for the new application into either a new stored procedure that gets called in the IF branch for the new application, or using parameterized dynamic SQL, will hide it away enough during compile-time, but do just fine at execution time.
further reading