• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1679
  • Last Modified:

Global Variable in MS SQL?

Is there global variable on
MS SQL 7? Or, is there anything
to use instead global variable?
When I say global variable, I mean
variable that last during one session.

1 Solution
Gustavo Perez BuenrostroCommented:

You cannot create your own global variables. Remember that global variables are predefined and maintained by the MS-SQL.

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:
Guy Hengel [angelIII / a3]Billing EngineerCommented:
As your "global variables" only need to be maintained during a session, your tables can be temporary tables (##GlobalVars), that will be dropped automatically when session ends..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now