jenlion
IS-IT--Management
- Nov 13, 2001
- 215
How do I get %windir% or %temp%?
I am doing a bcp to a file. %temp% works fine for that. But then, when I do this:
I get this:
If I set @FileName to c:\something, works great. Set it to %temp%\something, no good. File is created fine; email is what fails. I guess it doesn't like the relative name.
I see I can get the Program Files directory by reading the registry, but I can't find windir or temp dir in the registry (maybe not doing the right search?).
Can someone tell me how to get the actual location? I'd like to do something like this, if you know what I mean:
declare @tempdir varchar(100)
set @tempdir = getdir(%temp%)
set @FileName = @TempDir\something
I am doing a bcp to a file. %temp% works fine for that. But then, when I do this:
Code:
EXEC master.dbo.xp_sendmail
@recipients = @emailaddr,
@message = @message,
@Subject = N'Your order has shipped',
@attachments = @FileName
Code:
Server: Msg 18025, Level 16, State 1, Line 0
xp_sendmail: failed with mail error 0x80004005
If I set @FileName to c:\something, works great. Set it to %temp%\something, no good. File is created fine; email is what fails. I guess it doesn't like the relative name.
I see I can get the Program Files directory by reading the registry, but I can't find windir or temp dir in the registry (maybe not doing the right search?).
Can someone tell me how to get the actual location? I'd like to do something like this, if you know what I mean:
declare @tempdir varchar(100)
set @tempdir = getdir(%temp%)
set @FileName = @TempDir\something