Sql-Server

錯誤:無法刪除證書,因為一個或多個實體已使用它進行簽名或加密

  • April 14, 2019

SQL Server 2008r2

我正在嘗試刪除我創建的證書,但出現以下錯誤

無法刪除證書,因為一個或多個實體已使用它進行簽名或加密

使用這個查詢我已經確定了有問題的實體

SELECT SCHEMA_NAME(so.[schema_id]) AS [SchemaName],
      so.[name] AS [ObjectName],
      so.[type_desc] AS [ObjectType],
      ---
      scp.crypt_type_desc AS [SignatureType],
      ISNULL(sc.[name], sak.[name]) AS [CertOrAsymKeyName],
      ---
      scp.thumbprint
FROM sys.crypt_properties scp
INNER JOIN sys.objects so
       ON so.[object_id] = scp.[major_id]
LEFT JOIN sys.certificates sc
       ON sc.thumbprint = scp.thumbprint
LEFT JOIN sys.asymmetric_keys sak
       ON sak.thumbprint = scp.thumbprint
WHERE   so.[type] <> 'U'
AND ISNULL(sc.[name], sak.[name]) = 'Certificate_name'
ORDER BY [SchemaName], [ObjectType], [ObjectName], [CertOrAsymKeyName];

在此處輸入圖像描述

但是當我嘗試使用以下語句刪除簽名時:

DROP SIGNATURE FROM OBJECT::dbo.sp_sqlagent_notify BY CERTIFICATE Certificate_name

我讓他們跟隨錯誤。

證書“Certificate_name”的簽名不存在。

我究竟做錯了什麼?

提前致謝。

我的錯。

我應該使用

DROP COUNTER SIGNATURE FROM OBJECT::dbo.sp_sqlagent_notify BY CERTIFICATE certificate_name

代替

DROP SIGNATURE FROM OBJECT::dbo.sp_sqlagent_notify BY certificate_name

引用自:https://dba.stackexchange.com/questions/175415