Run Teradata SQL Assistant via a batch script - batch-file

I am trying to Run a teradata SQL script via a batch script and export the details.
I have managed to execute the whole thing in DOS which is great
Im just not sure how to package it up
Below is my very average attempt. COuld anyone point me in the right direction?
The SQL is SELECT DATE
#title Optional Title
#echo off
C:\'Program Files (x86)'\Teradata\Client\15.00\Teradata SQL Assistant\
Sqla -c DB_NAME -f "C:\Temp\test.sql" -e "c:\Temp\test_output.log"
Thanks

I found the answer on another different question on Stack Overflow
How do I execute cmd commands through a batch file?
This basically does what i need or at least points me in the correct direction
Thank you for your time

Related

Passing values from Batch to DB2

I am really new to Batch and DB2 and got little time to explore much about them. I just want to know how it is possible for a batch program to pass a value/s to a db2 file so I can manipulate my database.
I found several suggestions but none of them worked. Here's my batch codes so far:
Rem This is db2execute.bat
#echo off
db2cmd -c -w -i db2 -tf INSERT.db2 id=1
PAUSE
My .db2 file on the other hand:
CONNECT TO SAMPLEDB;
INSERT INTO TB1 VALUES('$(ID)');
I would really appreciate some kind help. Thanks.
At the present time, in the shipping versions of Db2-LUW, the CLP (command line processor) does not directly support parameters in script files in the style that your question suggests.
If your product-type and version offers the clpplus command, then you can instead try using the Oracle sqlplus style for passing parameters on the command line and referencing those parameters in your script. See the Db2 and Oracle documentation for details .

Run custom script in SQL Server Express

I am trying to run a script on Task Scheduler to update a column in my database every 1 hour.
I have table vw_invoices and a column ExportLock with a default value of 0 which is "unlocked".
I want to run a query to update ExportLock to 1. Currently I am running
update Worldwide.dbo.vw_Invoices
set ExportLocked = 1
I really appreciate your help.
USE SQLCMD along with windows task scheduler to mimic SQL Agent on SQL Server Express:
sqlcmd
-S <ComputerName>\<InstanceName>
-i <c:\MyScript.sql>
-o <c:myutput.txt
Keep the above in a notepad and save it as .BAT file and schedule through task scheduler
I found what I was looking for and here is what I did worked great, I appreciate everyone's help

Running sql files to update database daily

I get a zipped file of sql dumps everyday. I unzip it, and then run this script everyday using a task scheduler to update the database.
#echo off
ECHO %USERNAME% started the batch process at %TIME% >output.txt
for %%f in (C:\Users\Desktop\Crash\*.sql) do (
sqlcmd.exe -S HUTRC1-HP -U sa -P hutrc#2121 -d test -i %%f >>output.txt)
exit
The database doesn't however get updated all the time. Let's just say it is not very reliable. There are some days when it is current, and other days when it's not current. Can't explain why. Is there more efficient script to update the database with? Preferably in powershell.
Creating an SSIS package will help you and achieve all that you want with better error handling.
There are multiple articles out there and a bunch of youtube videos. A youtube video can help you accomplish what you need in no time. Here are some articles that i quickly got off of msdn.
How to create an SSIS package.
How to unzip files in SSIS package without any C# knowledge
How to automate an SSIS package.
Hope this helps.

auto run batch file containing db2 statements in windows

I want Task Scheduler in Window run DailyJob.bat daily at a certain time, this file having content like this:
#echo off
DB2 CONNECT TO dbName USER usrName USING password
DB2 .........
DB2 ..........
Moreover, Task Scheduler will run this file by cmd.exe automatically, but cmd doesn't understand DB2 command. Please help me, thanks !
You need to call your db2 statements with the db2cmd command (http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002036.html?cp=SSEPGG_10.5.0%2F3-6-2-6-35)
From CMD.exe
db2cmd -i -c db2 list node directory
There are a lot of related questions in the Web about this problem.

Executing an sql batch file within a seperate batch file

I am running a 2008 SQL server. I am using remote backup to backup the server and have two batch files to trigger the backup process. The first batch file contains:
#echo off
CALL "" "C:\Scripts\SQL Maintainence\Nightly Maintenance 2008 SSE.bat"
The second batch file (Nightly Maintenance 2008 SEE) looks like this:
#echo off
osql -S %SERVER% -d msdb /U (username) /P (password) -i "Nightly Maintenance 2008 SSE.sql" -o "Nightly Maintenance 2008 SSE.txt"
For some reason, the first batch file is not calling for the second batch file to run, the script works when manually ran.
I am very new to writing batch files and have done quite a bit of research up to this point. Any help or maybe an article that can help with my issue would be greatly appreciated.
Reposted as answer instead of question...
I think you need to delete the "" immediately after the CALL, like this:
CALL "C:\Scripts\SQL Maintainence\Nightly Maintenance 2008 SSE.bat"

Resources