Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2004, 05:59 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to create Global Variable

Hi all

I want to create a global variable which i want to use in a trigger

can you help me?


thanks

 
Old September 23rd, 2004, 10:14 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

I believe that using SQL 7. and above Global Variables are considered functions. Search Books online for Global variables.

 
Old September 23rd, 2004, 03:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you explain on what you are trying to achieve?

To my knowledge Global Variables in sql server are all server defined, all that are prefixed with @@, which cannot be assigned values by a user, but they are assigned values based on activities performed on the server.

Eg: @@ERROR contains ZERO when a last executed transcation is successfully done. Else a non zero value is stored in it.

If you are looking for user defined variables that needs to be global, I am not sure if you can declare something like that in one set of code and use that in another set of code. I don't think that is possible.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 27th, 2004, 03:37 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Anantsharma Send a message via Yahoo to Anantsharma
Default

HI,

I feel you have some special purpose and case. If not you can just use @@ to declare a global variable in the way :-

Declare @@MyName Varchar(30)

Once you fired this statement, u have a global variable.

Now you can use it :-

Set @@MyName ='B. Anant'

Select @@MyName as [My Name]
......
.....
....

Hope this helps.
 
Old September 30th, 2004, 07:11 AM
Authorized User
 
Join Date: Sep 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Lalit_Pratihari
Default

Hi Anant,

I have worked on ur given example but it is not working.
Could you please suggest us a better way.


Thanks,

Lalit
Life Means More...;)
 
Old September 30th, 2004, 08:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Anant,

I don't think users are let to create global variables with prefix @@. I don't find any document supporting that. Can you confirm if that works as you suggested?

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
comapring global variable value to local variable amhicraig XSLT 6 December 5th, 2007 12:16 PM
Global Variable techfreak123 XSLT 0 August 3rd, 2006 07:45 AM
global variable? milk_vanilla Classic ASP Basics 3 January 8th, 2005 06:50 PM
global variable in c# kobystud C# 3 April 22nd, 2004 05:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.