exec master..xp_cmdshell 'set'
I need to get a temporary OS directory without resorting to using xp_cmdshell. I am using MSSQL 2008. How can I do this?
Well, there seems to be no way to do this from TSQL. I believe that SQL Server knows about% temp% because it should use it, but well.
Well, can anyone recommend a way to make this code more compact / dense?
Set NoCount On
Declare @t VarChar(256)
Declare @env Table ( [Parts] VarChar(256) )
Insert Into @env
Exec Master..Xp_CmdShell 'set'
Set @t = ( Select Top 1 [Parts] From @env Where [Parts] Like 'temp=%' )
Select Replace(@t , 'temp=','' )
Thank.
Snowy source
share