Solved

Call SQL Job after insert on CDC table

Posted on 2014-02-26
6
847 Views
Last Modified: 2016-02-10
Hello Experts!! I am trying to call a SSIS job to process some ETL after I make an insert into
a table.

This table has CDC enabled on it, and I want to basically just trigger the SSIS job after there has been an insert into the table so the job doesn't constantly run without grabbing new data.

Basically I have one server with my database with CDC enabled on it and then my package server running my SSIS jobs.

So far I have been unsuccessful by creating a trigger and then using cmdshell to call my SQL Server job having my SSIS package.

I'm running SQL Server 2012 SP1

Do you guys have any ideas?

Thanks!
0
Comment
Question by:rmm2001
6 Comments
 
LVL 15

Expert Comment

by:tim_cs
ID: 39889187
0
 
LVL 7

Author Comment

by:rmm2001
ID: 39889202
I'm trying to call it via an xp_cmdshell action on the package server. I get this error .. (not sure if it helps):

The EXECUTE permission was denied on the object 'xp_cmdshell', database 'mssqlsystemresource', schema 'sys'.
Failed to insert rows into Change Data Capture change tables. Refer to previous errors in the current session to identify the cause and correct any associated problems.
0
 
LVL 26

Accepted Solution

by:
Zberteoc earned 250 total points
ID: 39890080
You should never attempt that! A trigger that will do a xp_cmdshell call. Imagine that trigger is fired 10000 times after an insert or update. Better create a job that will execute the SSIS  every minute and check if the table changed and if yes then execute it.

The trigger to call sp_cmdshell is definitely not the way to go.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 35

Assisted Solution

by:David Todd
David Todd earned 250 total points
ID: 39891142
Hi,

One of the great errors in writing triggers is from the point of view of the ui. That is one row gets updated/inserted, and the trigger fires once.

What happens if 100 rows get updated by the dba? The trigger fires once for the update, and if not written correctly will fail.

Now, the insert/update will not complete, that is the signal will not go back to the UI or whatever, until the trigger completes.

So one way to use the trigger, is to insert into a table the rowID of the row inserted/updated, and a timed job inspects that table for rows to process. Way better. That is, if the process will have difficulty deteriming if a row has changed = which could use timestamps, rowlastupdatedatetime, whatever.

HTH
  David
0
 
LVL 7

Author Comment

by:rmm2001
ID: 39900847
60 second delay is not acceptable in this situation. I think i've found an alternative solution that we are going to implement.
0
 
LVL 26

Expert Comment

by:Zberteoc
ID: 39901141
Thanks for the points but just out of curiosity, can you share that solution?
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to merge 3 large tables into one Table in SQL server 2 19
SSIS GUID Variable 2 30
SQL Server Trigger 8 33
Regarding Disk IO 3 41
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question