How to access environmental variables within SQL

How to access environmental variables within SQL

Post by Brian HO » Fri, 27 Jun 2003 11:03:29



Anyone can help as I would know how to access
environmental variables within SQL.

It seems that for
insert table exec xp_cmdshell 'set'

it will not get all the environmental variables...

Thanks.

 
 
 

How to access environmental variables within SQL

Post by SriSam » Fri, 27 Jun 2003 11:33:29


I don't think this is possible.
--
HTH,
SriSamp
Please reply to the whole group only!


Quote:> Anyone can help as I would know how to access
> environmental variables within SQL.

> It seems that for
> insert table exec xp_cmdshell 'set'

> it will not get all the environmental variables...

> Thanks.


 
 
 

How to access environmental variables within SQL

Post by Jacco Schalkwij » Fri, 27 Jun 2003 12:19:32


You can read them from the registry using the undocumented system stored
procedure xp_regread (see here
http://www.databasejournal.com/features/mssql/article.php/1441251 for more
info)

User environment variables are in HKEY_CURRENT_USER\Environment, system
environment vriables are in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment.

--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.


Quote:> Anyone can help as I would know how to access
> environmental variables within SQL.

> It seems that for
> insert table exec xp_cmdshell 'set'

> it will not get all the environmental variables...

> Thanks.

 
 
 

How to access environmental variables within SQL

Post by Narayana Vyas Kondredd » Fri, 27 Jun 2003 13:25:49


The following does bring back all environmental variables for me: insert
table exec xp_cmdshell 'set'

--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
What hardware is your SQL Server running on?
http://vyaskn.tripod.com/poll.htm


Anyone can help as I would know how to access
environmental variables within SQL.

It seems that for
insert table exec xp_cmdshell 'set'

it will not get all the environmental variables...

Thanks.

 
 
 

How to access environmental variables within SQL

Post by Brian HO » Fri, 27 Jun 2003 19:29:36


Thanks for the message.

To be more precise, would it be posible to get the variable a, which is
set by the batch command: 'set a=test'

so that the 'test' can be accessed within SQL.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!