SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Trigger after Insert?


Trigger after Insert?

Author
Message
obarahmeh
obarahmeh
Old Hand
Old Hand (351 reputation)Old Hand (351 reputation)Old Hand (351 reputation)Old Hand (351 reputation)Old Hand (351 reputation)Old Hand (351 reputation)Old Hand (351 reputation)Old Hand (351 reputation)

Group: General Forum Members
Points: 351 Visits: 309
Dear all, I've a table that is modified daily and has a huge amount of data, and for performance issue, I need to insert the latest daily data into a another table to perform search operations with better spped, and so, I think I need to write a trigger after insert on the first table to insert the latest rows in the other table.
How can I do that?
jacob sebastian
jacob sebastian
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2794 Visits: 2523
From inside your trigger, you can access the INSERTED virtual table. This table will have the same structure as your main table and contain only the newly inserted data. You can then write an INSERT INTO statement which SELECTS columns FROM INSERTED.

.
Suresh B.
Suresh B.
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5222 Visits: 5330
and for performance issue, I need to insert the latest daily data into a another table to perform search operations with better spped


Have you created any indexes to improve the search?
Any horizontal partitions?

I feel, creating a new table is not a good idea, just for search operation. Trigger may cause performance issue.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search