Run script in Kettle from records in table - pentaho

I have a table where multiple SQL scripts. I would like to make an ETL that runs these scripts on another bank line by line. We built a SQL editor that is used by multiple users, what we need to do now is that they run at a certain time of day by ETL.

You can use a Table Input step in a transformation to read this table with these scripts. You can then hop the Table Input step to an Execute Row SQL Script step to execute the SQL scripts from the "script" column row-by-row.

Related

SSIS Incremental Load-15 mins

I have 2 tables. The source table being from a linked server and destination table being from the other server.
I want my data load to happen in the following manner:
Everyday at night I have scheduled a job to do a full dump i.e. truncate the table and load all the data from the source to the destination.
Every 15 minutes to do incremental load as data gets ingested into the source on second basis. I need to replicate the same on the destination too.
For incremental load as of now I have created scripts which are stored in a stored procedure but for future purposes we would like to implement SSIS for this case.
The scripts run in the below manner:
I have an Inserted_Date column, on the basis of this column I take the max of that column and delete all the rows that are greater than or equal to the Max(Inserted_Date) and insert all the similar values from the source to the destination. This job runs evert 15 minutes.
How to implement similar scenario in SSIS?
I have worked on SSIS using the lookup and conditional split using ID columns, but these tables I am working with have a lot of rows so lookup takes up a lot of the time and this is not the right solution to be implemented for my scenario.
Is there any way I can get Max(Inserted_Date) logic into SSIS solution too. My end goal is to remove the approach using scripts and replicate the same approach using SSIS.
Here is the general Control Flow:
There's plenty to go on here, but you may need to learn how to set variables from an Execute SQL and so on.

Add an Update SQL Query on a Pentaho Kettle Transformation

I have a scenario where I would like to run an update script after a table input and table output job, can anyone assist? I have tried these four but I can't seem to figure out how to make them work.
My Current Transformation
Here's the scenario...
Table Input: MySQL Database Table1 (*Select * from Table1*)
Table Output: Oracle Database (Create Table 1)
(this runs well to completion but then I have to execute the update script manually. I am looking for a way to automate this)
The update query I would like to run:
*update odb.table1 set colum1='New Value1' where column1='Old Value1'
update odb.table1 set colum1='New Value2' where column1='Old Value2'*
Thank you in advance.
I used the Execute SQL Script tool. I just added the two update queries separated by a semicolon ;.
I created two transformations. One for the table input and table output and another for the Execute SQL Script Tool.
I then created a Kettle Job and placed my query after the table output transformation.

Generate script in SQL Server Management Studio

If I have a table with data in a database in SQL Server, how can I generate a script that will create the table and add the data too?
If I right click on the table then select Script Table As > Create to > File, that generates a script to just create the table without the data. What I need is a script that creates the table and adds the data that is already existing in the table or 2 separate scripts, one that creates the table and one that adds the data.
Here what you have to do:
right click the database (not the table) and select tasks --> generate scripts
Next --> select the requested table/tables (from select specific database objects)
next --> click advanced --> types of data to script = schema and data
next and finish
Use SSMS scripting feature (Rightclick on database->Tasks->Generate Scripts)
or
use SSMS Tools Pack
Here You can see step by step process of Generate script in SQL Server Management Studio :
Step 1: Right Click on Your Database --> Select Task-->Generate Script..
Step 2: Select Next in Script Wizard
Step 3: Select Script Entire Database
Step 4:Choose Your File Name
and Finish
Now you can use your script file.
Be aware that generating scripts (schema and data) does not export duplicate ROWS
Do a test (only need 2 columns and half a dozen rows) - I wondered what was happening - in the end it turned out to be a good thing in this instance

SQL Server Script Database with Seed Data

I am creating an install script for a Sql server 2008 database using Tasks =>generate Scripts option. This works fine and creates a script including database,schema and seed data.
One problem I notice is that the A Stored procedure is created before the table it refers to is created and this gives error when creating the database.
I don't think there's any built-in functionality for ordering the scripting, but you could split them up in separate scripts and control the order in which those are executed yourself.
For example, select just the tables and generate a tables create script, then select the sprocs and generate another script.

Move data from one table to another every night SQL server

I have this scenario i have a staging table that contains all the record imported from a XML file .Now i want to move this data based on verification like if the record is already in the other table update the record other wise insert the new record. i want to create a job or scheduler in SQL Server that do this for me every night without using any SSIS packages.
Have you tried using the MERGE statement?
SSIS really is an easy way to go with something like this, but if necessary, you can set up a a SQL server agent job. Take a look at this MSDN Article. Basically, write your validation code in a stored procedure, then create a job with a TSQL job step which calls that stored procedure.