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

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

  •  03-04-2022
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução

bcp "EXEC %db%.dbo.EXPORT_TABLE" queryout dataout.txt -SMYSERVER -T -c -r"\n" -t"" > output.txt
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top