February 19, 2008 at 3:47 am
Hi,
I have written an SP which will export the data from sql server to text file. I have used BCP with xp_cmdshell. But in my production server, we don't have rights to run the XP_CMDSHELL command.
Is there any way to execute the bcp without xp_cmdshell command ??
Any other method to export the data from sql server to text file???
February 19, 2008 at 3:51 am
If the text file already exists, OPENROWSET.
Or you could give DTS a try.
N 56°04'39.16"
E 12°55'05.25"
February 19, 2008 at 3:19 pm
There's a command line version of bcp. See BOL.
February 19, 2008 at 8:41 pm
If you have a "friendly" DBA, (s)he will be able to setup a proxy user on a job that anyone could run at any time.
Good lesson here, though... most DBA's do not allow the adhoc usage of anything that requires "SA" privs including xp_CmdShell and the sp_OA* procs. Always check with the DBA before writing such code. It's their box and they typically have the right to refuse any code they believe to be "dangerous to the data or the server".
--Jeff Moden
Change is inevitable... Change for the better is not.
February 20, 2008 at 2:57 pm
[font="Arial"]
Hello,
We use the command line version of bcp from within a .bat to export data from the 'working' tables. Runs quick and works reliably. Since you are in a .bat you can also direct the output of the program and produce any log files to help you trouble shoot if something occurs.
Here's a sample of a bcp command line:
rem create output file for invalid data
bcp %DATABASE%.dbo.workingTable01 out -c -e -r\r -S %SERVERNAME% -T -e %LOGS%\workingTable01.log
I hope this helps.
Regards,
Terry
[/font]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply