Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute stored procedure from cmd.exe?

Is there anyway to run a stored proc from cmd.exe ?

p.s.
I know how to create exec file c# and to run it.

I'm asking without any code :

Just me and cmd.exe.

edit

me and cmd.exe : meaning I don't want to write any code. Internal SQL Server help exe files of sql is fine !

sorry for not clarifying this !

like image 325
Royi Namir Avatar asked Dec 31 '11 13:12

Royi Namir


Video Answer


2 Answers

Try using the SQLCMD Utility :

An example:

sqlcmd -E -S server_name -d database_name -Q "EXEC schema.storedprocedure parameter01, parameter02"

If you'd like to explore other options I'd like to share this link:

Command Prompt Utilities: Applicable for SQL Server 2005

like image 85
Nonym Avatar answered Oct 06 '22 19:10

Nonym


  • For sql server 2005+ use its SQLCMD utility, as @Nonim answered
  • for versions prior to 2005 use its OSQL utility, its usage is similar to SQLCMD

Wrap it into the .cmd file and you're in! No needs to write something, just click'n'go! 8-)

like image 23
Oleg Dok Avatar answered Oct 06 '22 20:10

Oleg Dok