Skip to content

Instantly share code, notes, and snippets.

@James-McNeill
Created January 17, 2022 15:45
Show Gist options
  • Save James-McNeill/a076ccc08438f58ffa19561ec5526d1b to your computer and use it in GitHub Desktop.
Save James-McNeill/a076ccc08438f58ffa19561ec5526d1b to your computer and use it in GitHub Desktop.
-- Declare the variable (a SQL Command, the var name, the datatype)
DECLARE @counter INT;
-- Set the counter to 20
SET @counter = 20;
-- Print the initial value
SELECT @counter AS _COUNT;
-- Select and increment the counter by one
SELECT @counter = @counter + 1;
-- Print variable
SELECT @counter AS _COUNT;
-- Select and increment the counter by one
SELECT @counter += 1;
-- Print the variable
SELECT @counter AS _COUNT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment