Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL counter variable @Count += 1

I would like to know if it's possible to create a Count variable like you would in C#.

DECLARE @Count Int
SET @Count = 0

--something happens
SET @Count += 1

--something happens
SET @Count += 1

IF @Count < 3
BEGIN
--Do something
END
like image 518
Pomster Avatar asked Mar 23 '26 01:03

Pomster


1 Answers

In SQL-Server you can do It in following:

SET @count = @count + 1
like image 165
Stanislovas Kalašnikovas Avatar answered Mar 24 '26 13:03

Stanislovas Kalašnikovas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!