Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CREATE INDEX whatever ON dbo.Users(Reputation);
GO
ALTER FUNCTION dbo.BeatIt(@Reputation INT)
RETURNS TABLE
AS
RETURN
SELECT *
FROM dbo.Users AS u
WHERE u.Reputation = @Reputation;
GO
ALTER PROCEDURE dbo.BeatThat(@Reputation INT)
AS
SET NOCOUNT, XACT_ABORT ON;
BEGIN
DECLARE @ReputationFix INT;
SET @ReputationFix = @Reputation;
IF @ReputationFix NOT BETWEEN 1 AND 2000000
BEGIN
SET @ReputationFix = 1;
END
SELECT *
FROM dbo.BeatIt(@ReputationFix) AS bi;
END;
EXEC dbo.BeatThat @Reputation = 1;
EXEC dbo.BeatThat @Reputation = 2;
DBCC FREEPROCCACHE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment