tags:

views:

39

answers:

2

Hi, I would like create a GLOBAL VARIABLE in a Sql script. For my understanding using DECLARE I will be able to create just LOCAL variable.

Any idea how to create theem?

thanks

+1  A: 

Why don't you just create a table do hold the system wide data you need?

krock
+3  A: 

Assuming MS SQL Server, and assuming the MS definition of 'Global Variable' you cannot. If you need a variable to be accessable across multiple stored procedures, or ad-hoc queries, you will need some other way to hold the data: say a table which holds the variable for you.

Note: the hyperlink does not go to Microsoft, I could not find a copy of Microsoft's specific definition, but the website linked came close enough for this discussion.

AllenG