I'm getting:
Msg 8115 Arithmetic overflow error converting expression to data type int error
For this query:
DECLARE @x int
IF EXISTS ( SELECT * FROM Y)
BEGIN
SET @x = (SELECT max(Id ) from Y)+1
END
ELSE
BEGIN
SET @x = 1
END
I tried to cast Id to Big int and I also tried by changing x as Big int, but still getting same error.
declare @x bigintmax(Id)is the maximum value for thebiginttype?