过去几周,我在 ASP.NET Core Web 应用程序上添加或更新存储在本地 SQL Server 上的数据时遇到了一个奇怪的触发问题。我的数据库上只有表和视图,没有触发器,但是当我尝试通过 Linq 方法语法查询添加或更新数据时,Visual Studio 会抛出错误:
Microsoft.EntityFrameworkCore.DbUpdateException:无法保存更改,因为目标表具有数据库触发器。请相应地配置您的实体类型,请参阅 https://aka.ms/efcore-docs-sqlserver-save-changes-and-triggers 了解更多信息。
SqlException:如果 DML 语句包含 OUTPUT 子句而不包含 INTO 子句,则该语句的目标表“tbl_Countries”不能有任何启用的触发器。
我找到了克服这个问题的解决方案。解决方案是声明 Visual Studio 每个表都有 SQL Server 自动生成的触发器。
builder.Entity<tbl_Countries>().ToTable(tb => tb.HasTrigger("tr_dbo_tbl_Countries_05f5745b-9b96-4d32-b09e-4be5651c2649_Sender"));
base.OnModelCreating(builder);
一开始工作得很好,但 SQL Server 有时会生成一个新的触发器,我需要再次在 Visual Studio 中更改触发器的名称。 我不知道为什么 SQL Server 自动生成触发器以及如何克服它。如果我等待一段时间并刷新数据库中的表,触发器就会消失,但下次我尝试添加或更新数据时会自动生成。
我正在使用 SignalR 在我的 Web 项目上获取实时数据和 cookie 会话。
由于 SignalR 的依赖性,我还在 SQL Server 数据库上使用了
enable_broker
:
alter database myProjectDB
set enable_broker with rollback immediate
Visual Studio 上的完整错误详细信息:
Microsoft.EntityFrameworkCore.DbUpdateException
HResult=0x80131500
Message=Could not save changes because the target table has database triggers. Please configure your entity type accordingly, see https://aka.ms/efcore-docs-sqlserver-save-changes-and-triggers for more information.
Source=Microsoft.EntityFrameworkCore.SqlServer
StackTrace:
at Microsoft.EntityFrameworkCore.SqlServer.Update.Internal.SqlServerModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at myProject.Controllers.AdminController.CountryAdd(tbl_Countries cnt) in C:\myProject\Controllers\AdminController.cs:line 2017
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
SqlException: The target table 'tbl_Countries' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
这是自动生成的触发器之一:
USE [myProjectDB]
GO
/****** Object: Trigger [dbo].[tr_dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender] Script Date: 22.11.2023 00:52:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tr_dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender]
ON [dbo].[tbl_Countries]
WITH EXECUTE AS SELF
AFTER insert, update, delete
AS
BEGIN
SET NOCOUNT ON;
DECLARE @rowsToProcess INT
DECLARE @currentRow INT
DECLARE @records XML
DECLARE @theMessageContainer NVARCHAR(MAX)
DECLARE @dmlType NVARCHAR(10)
DECLARE @modifiedRecordsTable TABLE ([RowNumber] INT IDENTITY(1, 1), [CountryID] int, [CountryTR] nvarchar(100), [CountryEN] nvarchar(100), [CountryCode] nvarchar(2))
DECLARE @exceptTable TABLE ([RowNumber] INT, [CountryID] int, [CountryTR] nvarchar(100), [CountryEN] nvarchar(100), [CountryCode] nvarchar(2))
DECLARE @deletedTable TABLE ([RowNumber] INT IDENTITY(1, 1), [CountryID] int, [CountryTR] nvarchar(100), [CountryEN] nvarchar(100), [CountryCode] nvarchar(2))
DECLARE @insertedTable TABLE ([RowNumber] INT IDENTITY(1, 1), [CountryID] int, [CountryTR] nvarchar(100), [CountryEN] nvarchar(100), [CountryCode] nvarchar(2))
DECLARE @var1 int
DECLARE @var2 nvarchar(100)
DECLARE @var3 nvarchar(100)
DECLARE @var4 nvarchar(2)
DECLARE @conversationHandlerExists INT
SELECT @conversationHandlerExists = COUNT(*) FROM sys.conversation_endpoints WHERE conversation_handle = '448f807c-b788-ee11-9f46-f18931e3884f';
IF @conversationHandlerExists = 0
BEGIN
DECLARE @conversation_handle UNIQUEIDENTIFIER;
DECLARE @schema_id INT;
SELECT @schema_id = schema_id FROM sys.schemas WITH (NOLOCK) WHERE name = N'dbo';
IF EXISTS (SELECT * FROM sys.triggers WITH (NOLOCK) WHERE object_id = OBJECT_ID(N'[dbo].[tr_dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender]')) DROP TRIGGER [dbo].[tr_dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender];
IF EXISTS (SELECT * FROM sys.service_queues WITH (NOLOCK) WHERE schema_id = @schema_id AND name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender') EXEC (N'ALTER QUEUE [dbo].[dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender] WITH ACTIVATION (STATUS = OFF)');
SELECT conversation_handle INTO #Conversations FROM sys.conversation_endpoints WITH (NOLOCK) WHERE far_service LIKE N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_%' ORDER BY is_initiator ASC;
DECLARE conversation_cursor CURSOR FAST_FORWARD FOR SELECT conversation_handle FROM #Conversations;
OPEN conversation_cursor;
FETCH NEXT FROM conversation_cursor INTO @conversation_handle;
WHILE @@FETCH_STATUS = 0
BEGIN
END CONVERSATION @conversation_handle WITH CLEANUP;
FETCH NEXT FROM conversation_cursor INTO @conversation_handle;
END
CLOSE conversation_cursor;
DEALLOCATE conversation_cursor;
DROP TABLE #Conversations;
IF EXISTS (SELECT * FROM sys.services WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Receiver') DROP SERVICE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Receiver];
IF EXISTS (SELECT * FROM sys.services WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender') DROP SERVICE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender];
IF EXISTS (SELECT * FROM sys.service_queues WITH (NOLOCK) WHERE schema_id = @schema_id AND name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Receiver') DROP QUEUE [dbo].[dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Receiver];
IF EXISTS (SELECT * FROM sys.service_queues WITH (NOLOCK) WHERE schema_id = @schema_id AND name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender') DROP QUEUE [dbo].[dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_Sender];
IF EXISTS (SELECT * FROM sys.service_contracts WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17') DROP CONTRACT [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Insert') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Insert];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Update') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Update];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Delete') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Delete];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode];
IF EXISTS (SELECT * FROM sys.service_message_types WITH (NOLOCK) WHERE name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/EndMessage') DROP MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/EndMessage];
IF EXISTS (SELECT * FROM sys.objects WITH (NOLOCK) WHERE schema_id = @schema_id AND name = N'dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_QueueActivationSender') DROP PROCEDURE [dbo].[dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17_QueueActivationSender];
RETURN
END
IF NOT EXISTS(SELECT 1 FROM INSERTED)
BEGIN
SET @dmlType = 'Delete'
INSERT INTO @modifiedRecordsTable SELECT [CountryID], [CountryTR], [CountryEN], [CountryCode] FROM DELETED
END
ELSE
BEGIN
IF NOT EXISTS(SELECT * FROM DELETED)
BEGIN
SET @dmlType = 'Insert'
INSERT INTO @modifiedRecordsTable SELECT [CountryID], [CountryTR], [CountryEN], [CountryCode] FROM INSERTED
END
ELSE
BEGIN
SET @dmlType = 'Update';
INSERT INTO @deletedTable SELECT [CountryID],[CountryTR],[CountryEN],[CountryCode] FROM DELETED
INSERT INTO @insertedTable SELECT [CountryID],[CountryTR],[CountryEN],[CountryCode] FROM INSERTED
INSERT INTO @exceptTable SELECT [RowNumber],[CountryID],[CountryTR],[CountryEN],[CountryCode] FROM @insertedTable EXCEPT SELECT [RowNumber],[CountryID],[CountryTR],[CountryEN],[CountryCode] FROM @deletedTable
INSERT INTO @modifiedRecordsTable SELECT [CountryID],[CountryTR],[CountryEN],[CountryCode] FROM @exceptTable e
END
END
SELECT @rowsToProcess = COUNT(1) FROM @modifiedRecordsTable
BEGIN TRY
WHILE @rowsToProcess > 0
BEGIN
SELECT @var1 = [CountryID], @var2 = [CountryTR], @var3 = [CountryEN], @var4 = [CountryCode]
FROM @modifiedRecordsTable
WHERE [RowNumber] = @rowsToProcess
IF @dmlType = 'Insert'
BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Insert] (CONVERT(NVARCHAR, @dmlType))
IF @var1 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID] (CONVERT(NVARCHAR(MAX), @var1))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID] (0x)
END
IF @var2 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR] (CONVERT(NVARCHAR(MAX), @var2))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR] (0x)
END
IF @var3 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN] (CONVERT(NVARCHAR(MAX), @var3))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN] (0x)
END
IF @var4 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode] (CONVERT(NVARCHAR(MAX), @var4))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode] (0x)
END
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/EndMessage] (0x)
END
IF @dmlType = 'Update'
BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Update] (CONVERT(NVARCHAR, @dmlType))
IF @var1 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID] (CONVERT(NVARCHAR(MAX), @var1))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID] (0x)
END
IF @var2 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR] (CONVERT(NVARCHAR(MAX), @var2))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR] (0x)
END
IF @var3 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN] (CONVERT(NVARCHAR(MAX), @var3))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN] (0x)
END
IF @var4 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode] (CONVERT(NVARCHAR(MAX), @var4))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode] (0x)
END
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/EndMessage] (0x)
END
IF @dmlType = 'Delete'
BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/StartMessage/Delete] (CONVERT(NVARCHAR, @dmlType))
IF @var1 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID] (CONVERT(NVARCHAR(MAX), @var1))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryID] (0x)
END
IF @var2 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR] (CONVERT(NVARCHAR(MAX), @var2))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryTR] (0x)
END
IF @var3 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN] (CONVERT(NVARCHAR(MAX), @var3))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryEN] (0x)
END
IF @var4 IS NOT NULL BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode] (CONVERT(NVARCHAR(MAX), @var4))
END
ELSE BEGIN
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/CountryCode] (0x)
END
;SEND ON CONVERSATION '448f807c-b788-ee11-9f46-f18931e3884f' MESSAGE TYPE [dbo_tbl_Countries_a74d7aa1-fcb8-4881-ad40-6ea7b4e1af17/EndMessage] (0x)
END
SET @rowsToProcess = @rowsToProcess - 1
END
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000)
DECLARE @ErrorSeverity INT
DECLARE @ErrorState INT
SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE()
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState)
END CATCH
END
提前致谢
使用 SignalR 或 SQL 表依赖进行实时同步时,会自动创建此触发器。我们无法确定当前正在使用哪一个。 我们可以选择以一定的时间间隔检查触发器,然后将新触发器放在那里并删除旧触发器。我不知道这有多准确,这只是一个猜测解决方案。