Lets say I have a stored proc call MyStoredProc which recieved an int (@MyParam INT) datatype.
Let’s say I have an int declared in a script like this…
DECLARE @MyVar INT ;
SET @MyVar = 101 ;
I just wrote a long sql script where I do a LOT of this…
EXEC MyStoredProc @MyVar + 1 ;
I am shocked that this is causing a syntax error warning.
I can do this…
EXEC MyStoredProc @MyVar ;
and I can do this…
EXEC MyStoredProc 101 ;
but I can’t do this…
EXEC MyStoredProc @MyVar + 1 ;
This is going to make my script a LOT harder to write unless I am missing something. This is for SQL 2005.
The only option I see is to declare a temp variable:
And create a Connect and User Voice topics proposing to extend T-SQL syntax.