Use batch to execute all SQL scripts in the folder and output the sqlplus content to the log file.

Source: Internet
Author: User
    1. @ Echo off
    2. Rem "set the Infos below, then it can be completed MED ."
    3. Rem "========================================"
    4. Rem "Please set the path of SQL Files"
    5. @ Set script_path = C:/temp
    6. Rem "Please set the connection of DB server"
    7. @ Set db_conn = dbusername/dbpassword @ dbsid
    8. Rem "========================================"
    9. Rem "get the time string"
    10. @ Set times = % Date:/= % time: = %
    11. Rem "get the time string"
    12. @ Set tmpf = TMP % times :~ 0, 14%. SQL
    13. @ Set logf = Log % times :~ 0, 142.16.txt
    14. Rem "specify the log file"
    15. @ Echo spool % logf %> % tmpf %
    16. Rem "only the error MSG"
    17. Rem @ echo set feedback off> % tmpf %
    18. Rem "copy the SQL file to tmpfile"
    19. @ For/R % script_path % A in (*. SQL) Do (
    20. Type % A >>% tmpf %
    21. Echo.> % tmpf %
    22. )
    23. Rem "write print log command to tmpfile"
    24. @ Echo spool off> % tmpf %
    25. Rem "Write exit; To tmpfile"
    26. @ Echo exit; >>% tmpf %
    27. Rem "perform the sqls"
    28. @ Sqlplus % db_conn % @ % tmpf %
    29. Rem "Del the tmpfile"
    30. @ Del % tmpf %
    31. @ Echo on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.