July 29, 2011 at 12:43 pm
Hello Everyone
I have a rather odd situation. I need to use a trigger that will execute a stored procedure, but only after the table has been loaded by an application that sits outside of the database.
This does not happen on any type of a timed schedule per se. Only once every few hours. The number of rows being inserted are very small. But after all the rows have been inserted, I need to execute a stored procedure that performs an update on the data. The only way that I know that a trigger will fire, is after each row is inserted, and that I do not want to have happen.
I simply every would use SQL Server for their data storage. Life would be simple that way.
Thanks in advance
Andrew SQLDBA
July 29, 2011 at 12:46 pm
--code to load the data.
--code to update the data.
Trigger is completely useless there.
July 29, 2011 at 12:46 pm
I don't think there is anyway for sql to know when another application is done sending update statements. Conceptually it just doesn't work. You could have the other application call your stored procedure are the end of its run. There is nothing that can tell sql "ok I am done inserting data now so you can do something else".
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 29, 2011 at 1:09 pm
Not that I can figure out. This is an old app that should have been done away with decades ago.
I have to use the insert statement within the app, and it will only allow an SELECT, INSERT, UPDATE or DELETE statement, it knows nothing else, and will error if I try to type anything else in that command area.
Thanks
Andrew SQLDBA
July 29, 2011 at 1:14 pm
I just thought of something after I sent the reply.
I can use either SSIS or a SQL job to query the table, and if there are rows in the table, then execute the sproc. The table gets truncated after every data load. So if there are rows in the table, then exec the sproc.
Helps to have someone to bounce ideas off of.
Thanks
Andrew SQLDBA
July 29, 2011 at 1:15 pm
Then you will have to use a trigger. There just is no way to conditionally fire a trigger based on a 3rd party application. You could your own nasty kludged thing that will plague you until you rip it out but really an insert trigger is the only way you are going to make this happen...or maybe a daily job that will update all the records since the last time it ran. You could set that up on a schedule that would work.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply