Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Branching proc
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