Skip to content

Instantly share code, notes, and snippets.

@James-McNeill
Created January 17, 2022 15:49
Show Gist options
  • Save James-McNeill/969226f35b3f28c50b30c49404126a09 to your computer and use it in GitHub Desktop.
Save James-McNeill/969226f35b3f28c50b30c49404126a09 to your computer and use it in GitHub Desktop.
-- Declare the initial value
DECLARE @counter INT;
SET @counter = 20;
-- Print initial value
SELECT @counter AS _COUNT;
-- Create a loop
BEGIN;
-- Loop code starting point
WHILE @counter < 30
SELECT @counter = @counter + 1;
-- Loop finish
END;
-- Check the value of the variable
SELECT @counter AS _COUNT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment