How would you execute a stored procedure in SQL Server (using windows authentication) from a batch file?
Asked
Active
Viewed 6.9k times
3 Answers
30
If you are using Sql Server 2005+, you can use sqlcmd utility.
Example:
sqlcmd -Q "exec storedProcName" -S YourServer -d YourDatabase -o C:\yourOutput.txt
dugas
- 11,576
- 2
- 42
- 51
-
and you put this in a .bat file and run using cmd? – Nitrodbz Oct 19 '12 at 18:54
-
1Yes, you can execute from a .bat file. – dugas Oct 19 '12 at 19:25
5
With SQL Server 2005 and above you can use sqlcmd.exe. More info about how to use it:
Robin V.
- 1,398
- 17
- 27