I have a case where i have got 10+ SQL script
.
I don't want to go and run all my scripts 1 by 1.
Is there a way that i can run all my scripts in succession in SQL Management studio
.
I found this post. Creating a batch file seems easier.
This is all you need:
@echo off
ECHO %USERNAME% started the batch process at %TIME% >output.txt
for %%f in (*.sql) do (
(
sqlcmd.exe -S servername -E -d databasename -i %%f >>output.txt
)
pause
Replacing servername and databasename, but it seems to be not working.
Any ideas?
If it's just "executed and there is no exception" - then just place all statements sequentially in stored procedure, and they will be executed sequentially. Computers are deterministic by design. If you execute these commands in a specific order, what makes you think they don't...
You've got an unmatched parenthesis, there. Try
for %%f in (*.sql) do sqlcmd.exe -S servername -E -d databasename -i %%f >>output.txt
I just saved it in a .cmd file and it appears to be working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With