I have several or more persistent tables that need to be rebuilt on a nightly basis.
To make these tables βliveβ as long as possible, as well as offer the ability to back up only data from the previous day, another developer vaguely suggested using a route similar to this when nightly builds:
create a persistent table (assembly version, e.g. tbl_build_Client)
rename the current table (tbl_Client is renamed to tbl_Client_old)
rename the build version to become a live version (tbl_build_Client is renamed to tbl_Client)
To rename tables, sp_rename will be used.
http://msdn.microsoft.com/en-us/library/ms188351.aspx
Do you see more effective ways to do this, or any serious pitfalls in the approach? Thanks in advance.
Refresh
Trying to discard the gbn response and recommendation to use synonyms, would this be a rational approach, or am I getting some part terribly wrong?
Three real tables for the "Client":
1. dbo.build_Client
2. dbo.hold_Client
3. dbo.prev_Client
Since "Client" is how other procs refer to "Client" data, the default synonym is
CREATE SYNONYM Client FOR dbo.hold_Client
Then follow these steps to update the data, but without interrupting access. (1.a.) TRUNCATE dbo.prev_Client (he had data yesterday)
(1.b.) INSERT INTO dbo.prev_Client records from dbo.build_Client, since dbo.build_Client still had data yesterday
(2.a.) TRUNCATE dbo.build_Client
(2.b.) INSERT INTO dbo.build_Client new data built from a new data collection process
(2.c.) change the synonym
DROP SYNONYM Client CREATE SYNONYM Client FOR dbo.build_Client
(3.a.) TRUNCATE dbo.hold_Client
(3.b.) INSERT INTO dbo.hold_Client entries from dbo.build_Client
(3.c.) change the synonym
DROP SYNONYM Client CREATE SYNONYM Client FOR dbo.hold_Client