Link to home
Start Free TrialLog in
Avatar of marti
marti

asked on

How to Declare a global variable in SQL Server

How can I declare a global variable in SQL Server?
I want this varaiable to be visible across multiple stored procedures.
Avatar of BrianWren
BrianWren

null
(oops... sorry, didn't mean to post.)
ASKER CERTIFIED SOLUTION
Avatar of Gustavo Perez Buenrostro
Gustavo Perez Buenrostro

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marti

ASKER

gpbuenrostro, could you please refer to a source which would clarify this article?
“Global variables are predefined and maintained by the system”.

The only way to resolve this problem is creating a table in which you must store the values of all your “global” variables and use a stored procedure to get the values from this table whenever you need them.

To get more detail see:

-"variables" definition on Glossary of BOL.
-Question 10198058 on EE:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=10198058 
Avatar of marti

ASKER

Thank you.