[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3731
  • Last Modified:

BCP - Running a stored procedure from the command line

I'm trying to run a stored procedure via BCP from the command line
using :-
bcp "exec databaseName.dbo.StoredProcName" queryout c:\export.txt -S serverName  -U userName -P passWord -c -t "," -k

But it doesn't work the error message is :-
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]BCP host-files must contain at least one column
0
Pete_Burke
Asked:
Pete_Burke
  • 2
1 Solution
 
dbaSQLCommented:
no, bcp is for copying data to or from sql.  if you want to run a proc, you should use osql.  do you need an example?
0
 
dbaSQLCommented:

osql /U userName /P password /d databasename /S servername /Q "storedprocname" -o c:\export.txt
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now