You want your proc to have two options? Like 'Incremental' and 'Full', is that right?
Full is easy, just add:
TRUNCATE TABLE ...
INSERT TABLE ... results of proc
to your proc.
Incremental is harder, but not that much, assuming you have a robust primary key in place. Use MERGE (or separate INSERT/UPDATE/DELETE statements, if preferred).
May 7, 2021 at 11:36 am
There may be a million details on this, but I'd start with two general concepts.
For emptying the table in order to reload it, TRUNCATE is your best bet. There are dependencies & gotchas around using it of course. However, it'll get the job done in most instances.
As for loading the table, I'd modify your procedure so that you use INSERT...SELECT syntax. That's the easiest way to get it done. That way, the existing query and the work you've done building are not in any way tossed aside.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 2 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply