After insert trigger - SQL Server 2008 -


i have data coming in datastage being put in our sql server 2008 database in table: stg_table_outside_data. ourside source putting data table every morning. want move data stg_table_outside_data table_outside_data keep multiple days worth of data.

i created stored procedure inserts data stg_table_outside_data table_outside_data , truncates stg_table_outside_data. outside datastage process outside of control, have within sql server 2008. had planned on using simple after insert statement, datastage doing commit after every 100,000 rows. trigger run after first commit , cause deadlock error come datastage process.

is there way set after insert wait 30 minutes make sure there wasn't new commit within time frame? there better solution problem? goal data out of staging table , working table without duplications , truncate staging table next morning's load.

i appreciate time , help.

one way take advantage of new merge statement in sql server 2008 (see msdn docs , this blog post) , schedule sql job every 30 minutes or so.

the merge statement allows define operations (insert, update, delete, or nothing @ all) depending on whether source data (your staging table) , target data (your "real" table) match on criteria, or not.

so in case, like:

merge table_outside_data target using stg_table_outside_data source  on (target.productid = source.productid)   -- whatever join makes sense  when not matched     insert values(.......)  when matched      -- nothing 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -