运行 在另一个会话中执行代码时并行事务
Run parallel transaction while executing code in another session
是否有可能 运行 在某个特定时间点更新,但在 different/parallel 会话中?在提供的示例中,我希望在 运行 WAITFOR
时某些特定更新为 运行。目前我有这个 WAITFOR
块有时间切换到另一个 SSMS(或其他工具)window/tab 和 运行 更新,同时等待 10 秒。从逻辑上讲,唯一需要做的就是在此时开始交易。
EXEC dbo.p_sync_from_accounts_ext_test @enable_snapshot_isolation = 1
, @run_update_flag = NULL
, @run_wait_for_10 = NULL
, @acc = @acc;
WAITFOR DELAY '00:00:10'; -- Execute update in parallel transaction
-- table update should be performed in that parallel transaction
EXEC dbo.p_finish_sync_attributes;
是的,你可以做到。
方法一: loop-back linked server(指向您当前服务器的链接服务器)未启用 DTC。从您的链接服务器调用您的 SP。
方法 2: 创建一个 SQL 服务器作业和 start the job programmatically.
请注意,在第一种情况下,您的更新语句必须包含在 SP 中。在第二种情况下,这是可取的,但不是必需的。
是否有可能 运行 在某个特定时间点更新,但在 different/parallel 会话中?在提供的示例中,我希望在 运行 WAITFOR
时某些特定更新为 运行。目前我有这个 WAITFOR
块有时间切换到另一个 SSMS(或其他工具)window/tab 和 运行 更新,同时等待 10 秒。从逻辑上讲,唯一需要做的就是在此时开始交易。
EXEC dbo.p_sync_from_accounts_ext_test @enable_snapshot_isolation = 1
, @run_update_flag = NULL
, @run_wait_for_10 = NULL
, @acc = @acc;
WAITFOR DELAY '00:00:10'; -- Execute update in parallel transaction
-- table update should be performed in that parallel transaction
EXEC dbo.p_finish_sync_attributes;
是的,你可以做到。
方法一: loop-back linked server(指向您当前服务器的链接服务器)未启用 DTC。从您的链接服务器调用您的 SP。
方法 2: 创建一个 SQL 服务器作业和 start the job programmatically.
请注意,在第一种情况下,您的更新语句必须包含在 SP 中。在第二种情况下,这是可取的,但不是必需的。