Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You should now have a fluidshell prompt similar to below

Image Modified


Set SQL Mode

FluidShell offers different modes which control how FluidShell interprets the commands you enter. Set the mode to "sql":

\cli sql

Image Modified


Connect to your Database

...

\change database northwind1

Image Modified


Enter Your SQL

...

DECLARE @today datetime 
set @today = DateAdd(dd, dateDiff(dd, 0, GetDate()),0)
select * from dbo.Orders where ShippedDate < @today

Image Modified


Run the \sqlexport Command on the SQL Buffer Contents

...

\sqlexport -f csv -o /Users/s/Desktop/output.csv

Image Modified


Verify the CSV is Created Correctly and Save Your Commands

...

runfluidscript-bundled.bat "-cSQLServer" "-fC:\Users\s\Desktop\sqlexport.fs"

Image Modified


Schedule the runfluidscript-bundled.bat Execution

...

You can now use the OS scheduler to automate running of this csv file on a daily basis. To launch the Windows Task Scheduler choose Start > Control Panel > Administrative Tools > Task Scheduler. When it opens, expand the Task Scheduler Library in the pane on the left and right click to Create Task and give it a meaningful name and description.

Image Modified

If you do not plan on being logged in when the script should run, check your Security options and make sure that you choose to allow the script to run whether you are logged out or not and with the highest privileges as shown below.

Image Modified

In the Triggers tab set your trigger for once a day at your desired time.

Image Modified

In the Actions tab of Windows Task Scheduler choose Action: Start a Program, browse to select runfluidscript-bundled.bat from within the Aqua Data Studio installation location.
Use the -cSQLServer -fC:\Users\s\Desktop\sqlexport.fs as arguments in the Actions details.
The -cSQLServer indicates the registered server in your connections and the -fC:\Users\s\Desktop\sqlexport.fs indicates the path to the FluidScript that contains all of your commands.

For "Start in", indicate the full directory path where Aqua Data Studio is installed and do not surround it with quotes.

Image Modified

Make sure you set the task to run once a day.

Image Modified

FluidShell also contains a sendmail command. Type \man sendmail to see the details of how this command works.

...