Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static variables

Status
Not open for further replies.

DomTrix

Programmer
Dec 28, 2004
94
GB
How can you set static variables in enterprise manager? I think 'static variables' is the correct term. Basically, I would like to do something like:

SELECT blah
FROM tableBlah
WHERE blahID = @@myStaticBlahID

Can I create and set these @@ variables in EM?

Thanks in advance

DT
 
use a userdefined function for this and hard code the value in there

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
Ok thankyou,

I am new to anything but SPs and general db design. Could you give me an example of how I might implement this (or soewhere where there is an example, can't find anything on google or here)? Would the UDF need calling to define the variable...?

DT
 
create FUNCTION dbo.GetID()
RETURNS INT
BEGIN
DECLARE @ID INT
SET @ID =1
RETURN (@ID)
END

--select dbo.GetID()


SELECT blah
FROM tableBlah
WHERE blahID = dbo.GetID()

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top