简体   繁体   中英

How to execute SQL queries from text files

I am using Aqua Data Studio 7.0.39 for my Database Stuff. I have a 20 SQL files(all contains sql statements, obviously).

I want to execute all rather than copy-paste contains for each.

Is there any way in Aqua to do such things.

Note: I am using Sybase

Thank you !!

I'm also not sure of how to do this in Aqua, but it's very simple to create a batch/powershell script to execute .sql files

You can use the SAP/Sybase isql utility to execute files, and just create a loop to cover all the files you wish to execute.

Check my answer here for more information: Running bulk of SQL Scripts in Sybase through batch

In the latest versions of ADS there is an integrated shell named FluidShell where you can achieve what you are looking for. See an overview here: https://www.aquaclusters.com/app/home/project/public/aquadatastudio/wikibook/Documentation15/page/246/FluidShell

The command you are looking for is source

source
NAME
source - execute commands or SQL statements from a file

SYNOPSIS
source [OPTION...] FILE [ARGUMENT...]
source [OPTION...]

DESCRIPTION
Read and execute commands or SQL statements from FILE in the current shell environment.

I have not used Aquafold before so I can't tell you exactly. However I have tackled a similar problem once before.

I once created a Powershell script. It opened a ODBC connection to my database and then executed stored procedures in a loop until end of file.

I suggest having a text document with each line being the name of an Stored Proc to run. Then in your powershell script read in a line from the file concatenate it into the call to execute a stored procedure. After each execution is completed you can delete the line from the text file and then read the next line until the EOF (end of file) is reached.

Hope this helps. If I have some time this morning I will try and do a working example for you and post it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM