Sql-server – Refreshing a table using CREATE TABLE, DROP and Rename

blockinglockingreplicationsql serversql-server-2008-r2

A read-only database (database1) is updated via log shipping every minute,
then a procedure queries multiple tables in it and refreshes a large table on database2.

For this process I

  • run an "expensive" query against database1 and generate a new Table in database2 (Table_A_TEMP)

    BEGIN TRAN
    DROP TABLE Table_A
    RENAME Table_A_TEMP to Table_A
    COMMIT
    

Does it look too ugly? Otherwise I would have to create a very complex verifications and updates.

Suggestions to minimize locks?

Best Answer

I have to update every minute. One person suggested me to rename the original table as well, I will try, it will probably be quicker, then I drop it after the commit.