exec master..xp_cmdshell 'set'
我需要獲取OS臨時目錄而不訴諸使用xp_cmdshell。我正在使用MSSQL 2008.我能做到這一點的最佳方式是什麼?SQL Server臨時目錄?
好吧,它看起來沒有辦法從TSQL做到這一點。我相信SQL Server知道%temp%,因爲它必須使用它,但是哦。
那麼任何人都可以推薦一種方法來使這個代碼更緊湊/更緊?
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=','')
謝謝。
這是驚人的,它不能被檢索。嗯。 – Snowy 2011-01-13 20:00:32