all groups > sql server msde > november 2004 >
You're in the

sql server msde

group:

How do I use a global variable as a selection criteria in a Transact SQL query?


Re: How do I use a global variable as a selection criteria in a Transact SQL query? William (Bill) Vaughn
11/18/2004 6:50:57 AM
sql server msde: Declare @MyVariable int
SELECT @MyVariable=@@GlobalVariable
SELECT col1 from mytable where x = @MyVariable

should work...

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

[quoted text, click to view]

How do I use a global variable as a selection criteria in a Transact SQL query? June Macleod
11/18/2004 12:28:29 PM
Can anyone tell me how I can use a global varible as a selection criteria in
a Query?


I previously had a query which I ran in MSAcces with the jet engine which
had in the criterial line a reference to a function which returned the value
of a global variable.

I have now moved to Access 2003 with an MSDE backend and this query no
longer works.

SELECT dbo.logTestQuestions.*
FROM dbo.logTestQuestions
WHERE (logTestID = getrerunid())

and in the Module the function is defined as:

Public Function getReRunID()
getReRunID = pr.rerunID
End Function

where pr.rerunID is a global variable.


When I run my query I get an error message of:

ADO error: 'getrerunid' is not a recognised function name




Many thanks

June

AddThis Social Bookmark Button