SQL 临时表和复制

发布于 2024-08-25 15:54:07 字数 676 浏览 7 评论 0原文

我的复制过程遇到问题,想挽救一些数据。我有一个流程,在将每个订户标记为重新初始化之前,我将连接到每个订户,并且我将运行以下命令来提取他们在“黑暗时间”期间可能输入的任何数据。

我很确定这在香草宫殿中会起作用。我不确定的是全局临时表是否会通过数据库复制持续存在。需要明确的是,我并不是试图复制 TempTable,我只是想确保复制后它仍然存在于本地数据库中,以便我可以从中运行 INSERT

想法?

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 PlanID = 407869
-- Drop Global Temp Table
DROP TABLE ##MyPlan
---------------------------
-- Run Replication Process
---------------------------

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 PlanID = 407869
-- Drop Global Temp Table
DROP TABLE ##MyPlan
---------------------------
-- Run Replication Process
---------------------------

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寻找一个思念的角度 2024-09-01 15:54:07

我非常确定全局临时表只有在至少一个连接使用它们时才会持续存在。如果没有更可靠的备份,我个人不想冒险,
即使它只是您在服务器上的不同数据库上创建的表,稍后您会删除它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文