Batch file to run sql command
RKL eSolutions Blogs. By Cliff Horst. Leave a Comment. You may also like. Read more. Need Support? Get in Touch. Blog Updates. Get blog updates by email. Simply fill in your name and email address and hit subscribe. Looking for something specific? Search the blog:. Quick Links.
Local Offices. Louis Syracuse Tampa Los Angeles. List of Services. Privacy Notice Blog Contact Us. Execute sql script in batch file with sqlplus command Ask Question. Asked 6 years, 2 months ago. Active 6 years, 2 months ago. Viewed 14k times. After some research I wrote this: sqlplus.
Is it the right conversion? Or have I done something wrong? I dont' want to modify the SQL script, so I'm hoping the problem is only in the batch file. Improve this question. Guillaume S. Guillaume 67 1 1 gold badge 1 1 silver badge 12 12 bronze badges. Do you get an error before it prompts you? Do you still get prompted if you use the -l flag? Create a free Team What is Teams? Collectives on Stack Overflow. Learn more.
How to run. Ask Question. Asked 11 years, 6 months ago. Active 7 years, 6 months ago. Viewed 26k times. Improve this question. Vishal Vishal I therefore went back to my roots and did it as an old-fashioned batch file, command file, call it what you will. Batch files are written in the scripting language for Microsoft command line shell. They typically have either the. BAT or. CMD extension. Batch files were supposed to be superseded by PowerShell. Against all expectations, DOS scripting has thrived.
There are plenty of DOS script archives, and a package manager for Windows Batch scripts written, of course, as a batch file. Plenty of grey-muzzle ops people have built up expertise with DOS shell batches and see no reason to change, or to convert their myriad scripts. The SQLCMD command-line executable is a wonderful tool, but you really need to use it frequently in order to remember all the important switches, Command-line Options, scripting variables and sqlcmd commands.
I use the technique by loading all or any of the procedures I need at the start of the sqlcmd script and the procedures remain throughout the script because everything is run in the same connection. No teardown is needed because the temporary procedures are deleted along with temporary tables when the connection is closed. The script stores the credentials in plain text in the user area, relying on NTFS security to prevent them being disclosed.
This is not that good, but a lot better that embedding UserIds or passwords in a script.
0コメント