sql - 触发后如何删除lockTable?
问题描述
我有一个触发器:
Create trigger Update_applicationUpdate_MainTable
on MainTable
after update
as
Update [SubTable] with(ROWLOCK)
set [LatUpdateTime] = SYSDATETIME()
where [dbo].[SubTable].[ClientTableId] in (select Id from inserted)
and [Table] = '[dbo].[MainTable]';
交易开始后:
update [dbo].[MainTable]
set [Name] = 'Test1'
where id = 1
锁定MainTable
andSubTable
进行另一笔交易。
如何只阻止一行?
我的第二个事务,但它挂起,因为触发器正在锁定表:
update [dbo].[MainTable]
set [Name] = 'Test1'
where id = 2
我只使用 SQL Server
解决方案
推荐阅读
- google-cloud-platform - GCP Terraform google_project_iam_member 不会将手动添加的角色删除到成员
- typescript - '{ pathname: string; 类型的参数 装运:TSshipment;}' 不可分配给“To”类型的参数
- hashicorp-vault - Vault 中转引擎自动开封在启动时未通过 VAULT_TOKEN?
- reactjs - 在 API 调用后反应重新渲染导致不良 UI 显示一瞬间
- python - 在 django 中,如何返回多对多连接的另一端?
- azure - 如何使用多个相互通信的应用服务设置 Azure 应用程序网关
- javascript - 使用 const 替换 attr 值
- excel - 比较两个工作表并将匹配项和唯一值粘贴到同一工作簿的不同工作表中
- c - 为什么 GCC -O0 转换按位与并乘以分支?
- xml - 使用 XSLT 将密钥添加到 XML 中的所有子节点到 MS Access 传输