Created
December 3, 2019 10:59
-
-
Save BrentOzar/d1c48c02ccd863a48f08bdeff2a1d025 to your computer and use it in GitHub Desktop.
Branching proc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE dbo.GetUnshippedOrders @IsShipped bit | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
IF @IsShipped = 1 | |
EXEC dbo.GetUnshippedOrders_UsesFilteredIndex | |
ELSE | |
SELECT OrderID, OrderDate FROM dbo.Orders WHERE IsShipped = @IsShipped; | |
END | |
GO | |
CREATE PROCEDURE dbo.GetUnshippedOrders_UsesFilteredIndex | |
AS | |
BEGIN | |
SELECT OrderID, OrderDate FROM dbo.Orders WHERE IsShipped = 0; | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment