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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to obtain the value of windows environment variable? 1

Status
Not open for further replies.

gcaramia

Programmer
Oct 30, 2003
185
IT
I need that a query returns the computername (or any other enviroment variable defined on a client)
Something as:
select "@@computername"
where computername is the name of pc where the query is invoked.

Is there a stored procedure or any other magic tip ?
Thanks
gianni
 



SELECT CONVERT(char(20), SERVERPROPERTY('servername'))
SELECT CONVERT(char(20), SERVERPROPERTY('machinename'))
SELECT HOST_NAME()

OR

DECLARE @NodeName varchar(30)
EXEC master.dbo.xp_regread
'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName',
'ComputerName',
@NodeName OUTPUT
select 'The active node is ' + @NodeName
 
SELECT HOST_NAME()

is what i'm looking for !!!

all others return the servername (computername where the instance of MSSQL is resident)

Thanks Jamfool
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top