Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How do I read the value of %temp%

Author  Topic 

SMerrill
Posting Yak Master

206 Posts

Posted - 2010-06-03 : 15:02:28
I need to get the value of the environment variable %temp% into a SQL string. Any ideas?

~ Shaun Merrill
Seattle area

Sachin.Nand

2937 Posts

Posted - 2010-06-03 : 15:13:06
Try something like this.I am not sure about the syntax.
exec master..xp_cmdshell '%temp%'

PBUH
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-06-03 : 15:38:50
I googled and found this
declare @val varchar(50)
create table #tbl (h varchar(50))
insert into #tbl exec master..xp_cmdshell 'echo %temp%'
set @val = (select top 1 h from #tbl)

Jim


http://stackoverflow.com/questions/856073/using-environment-variables-in-t-sql


select * from #tbl
drop table #tbl


Everyday I learn something that somebody else already knew
Go to Top of Page

SMerrill
Posting Yak Master

206 Posts

Posted - 2010-06-03 : 17:18:01
thanks a lot!

~ Shaun Merrill
Seattle area
Go to Top of Page
   

- Advertisement -