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