Solved

Call SQL Job after insert on CDC table

Posted on 2014-02-26
6
822 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

862 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

23 Experts available now in Live!

Get 1:1 Help Now