Often, in non-textbook situations, I’ve found I had to assign my variable from thing that isn’t hard-coded. It might be from something I need to get from within the data itself. It might be something that keeps changing all the time, like a count. Or it might be something that is going to be different between Development and Production environments.

Declare @MaxTempID Int
Select @MaxTempID = Max(TempID)
From TempsWithSubCos

DECLARE @activeCode int
SELECT @activeCode = CodeID FROM tblCodeTable WHERE GroupID = ‘6’ AND CODE = ‘A’