Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Adding Global and Scope Variables Expand / Collapse
Author
Message
Posted Sunday, September 25, 2011 4:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, October 9, 2013 1:06 AM
Points: 7, Visits: 71
There must be an life saving global variables to use per connection like:

DECLARE @@MYVAR1 BIGINT
DECLARE @@MYVAR2 VARCHAR(30)

SET @@MYVAR1 = 123456
SET @@MYVAR2 = 'Username'

So we can use it to pass or use them anywhere on the sql server.
For eg: When a user opens my application, I'll pass @@MYVAR1 and @@MYVAR2.
Then I'll assign fields default value to @@MYVAR1 and @@MYVAR2 so I never ever need to pass extra params from application to stored procedures or queries to save them in tables. Also this is very useful if you want to do table or record security works.
Post #1180614
Posted Thursday, September 27, 2012 6:53 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 10:41 AM
Points: 809, Visits: 1,996
I can see many uses for it. I can also see the two at sign notation carring on the "tradition" of temp tables.

Conversly would name spaces be better for this?
@session.myusername = 'Buford H. Pusser'
@server.panicphone = '202-456-1414'

Who gets to set server variables? Who gets to change them? When they get changed when do I see the effect of the change?



ATB

Charles Kincaid

Post #1365207
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse