At some point, you may have the need to rapidly apply a bunch of scripts on a particular database. Rather than manually opening each in Management Studio and executing them, you can use sqlcmd to run all scripts in a particular directory, in alphabetical order. Should save you some time:
for %f in (“c:\path\to\dir\*.sql”) do sqlcmd -S [SERVER_NAME] -d [DATABASE_NAME] -i “%f” -b
Great! Just what I needed today. Thanks
That’s what I need. But where do I run that code?
You can run it from a command prompt to run the scripts in your target directory.
Hi there! I am so grateful that I found your blog. I really admire the dedication you put into presenting the detailed information for free. I will definitely come back to your blog for more. Keep up the good work. By the way, this system helps me making around $650 per day, if you allow me, I suggest you to take a look at this secret offer page to access your very own turnkey software business to increase your online income. Wish you more success, all the best!