Solved

Call SQL Job after insert on CDC table

Posted on 2014-02-26
6
812 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

709 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now