Hello, I am wanting to take the output of sp_who2 to and
output file and then send that file in an email message
all within a PROC. I was thinking that I should
use "xp_cmdShell" and execute the BCP command. After
trying a number of times to get it to work, someone
provided me the following and indicated that it work find
on their machine. So all I did was change the server
address and run, but it still generates an error. Here
is the command:
master..xp_cmdshell 'bcp "exec master..sp_who" queryout
"C:\SQLTestOutput.txt" -c -T -S "Fred\NetSDK" '
Here is the error that I get.
usage: bcp {dbtable | query} {in | out | queryout |
format} datafile
[-m maxerrors] [-f formatfile] [-e
errfile]
[-F firstrow] [-L lastrow] [-b
batchsize]
[-n native type] [-c character type] [-w
wide character type]
[-N keep non-text native] [-V file format version] [-q
quoted identifier]
[-C code page specifier] [-t field terminator] [-r
row terminator]
[-i inputfile] [-o outfile] [-a
packetsize]
[-S server name] [-U username] [-P
password]
[-T trusted connection] [-v version] [-R
regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
NULL
(12 row(s) affected)
There is no output file created - so I can not tell if it
is telling me that I have a format error, or if this is
the type of message I would get if it works. If it
worked, where is the file?I figured it out - it did not like the command spread
over two lines.
>--Original Message--
>Hello, I am wanting to take the output of sp_who2 to and
>output file and then send that file in an email message
>all within a PROC. I was thinking that I should
>use "xp_cmdShell" and execute the BCP command. After
>trying a number of times to get it to work, someone
>provided me the following and indicated that it work
find
>on their machine. So all I did was change the server
>address and run, but it still generates an error. Here
>is the command:
>master..xp_cmdshell 'bcp "exec master..sp_who" queryout
>"C:\SQLTestOutput.txt" -c -T -S "Fred\NetSDK" '
>Here is the error that I get.
>usage: bcp {dbtable | query} {in | out | queryout |
>format} datafile
> [-m maxerrors] [-f formatfile] [-e
>errfile]
> [-F firstrow] [-L lastrow] [-b
>batchsize]
> [-n native type] [-c character type] [-w
>wide character type]
> [-N keep non-text native] [-V file format version] [-q
>quoted identifier]
> [-C code page specifier] [-t field terminator] [-r
>row terminator]
> [-i inputfile] [-o outfile] [-a
>packetsize]
> [-S server name] [-U username] [-P
>password]
> [-T trusted connection] [-v version] [-R
>regional enable]
> [-k keep null values] [-E keep identity values]
> [-h "load hints"]
>NULL
>(12 row(s) affected)
>There is no output file created - so I can not tell if
it
>is telling me that I have a format error, or if this is
>the type of message I would get if it works. If it
>worked, where is the file?
>.
>sql
没有评论:
发表评论