Executing bcp to export data from a stored procedure via cmd prompt WITHOUT xp_cmdshell

StackOverflow https://stackoverflow.com/questions/15934311

  •  03-04-2022
  •  | 
  •  

문제

I want to run a series of scripts in command shell every day. These will be executed from windows / shell -NOT FROM SQL directly.

I'm using bcp on a stored procedure that reformats the data. The stored procedure returns the correct data. Let's say my database is called MYDB and the procedure is called "MYSP" The server is MYSERVER

I'm trying combinations of things like:

BCP "EXEC MYDB.dbo.MYSP" -SMYSERVER  f "export_stuff.xml" queryout "test_export.dat" -T -c

Instead of doing anything useful or printing an error message, it just prints out the usage instructions.

What is the call?

도움이 되었습니까?

해결책

bcp "EXEC %db%.dbo.EXPORT_TABLE" queryout dataout.txt -SMYSERVER -T -c -r"\n" -t"" > output.txt
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top