SQL Temp Tables & Replication
I have had an issue with our replication process and would like to salvage some data. I have a process in place where I will connect to each subscriber before flagging them for reinitialization and I will run the below to pull any data they may have entered in during the "dark time".
I am pretty sure this will work in a vanilla palace. What I am unsure of is whether the Global Temporary Table
will persist through DB Replication. To be clear, I am not trying to Replicate the TempTable, I just want to make sure it will still exist at the local DB after the Replication so I may run the INSERT
from it.
Thoughts?
USE MemberCenteredPlan
-- Select Data from tblPLan
SELECT * INTO ##MyPlan
FROM tblPlan
WHERE PlanID = 407869
---------------------------
-- Run Replication Process
---------------------------
-- Insert Plan back into DB
INSERT INTO tblPlan
SELECT * FROM ##MyPlan
WHERE Pla开发者_如何学编程nID = 407869
-- Drop Global Temp Table
DROP TABLE ##MyPlan
---------------------------
-- Run Replication Process
---------------------------
I'm pretty sure that global temp tables only persist as long as at least one connection using them. I personally wouldn't want to risk it without having a more solid backup in place, even if it is just a table you create on a different database on the server, that you later drop.
精彩评论