我已经创建了证书,现在我想删除证书签名并删除证书。当我直接提供证书名称时,它正在工作,但是当我使用局部变量提供名称时,它会给我语法错误。
我也试过不同的数据类型
text, varbinary(max), char(200), varchar(200), nvarchar(200)
这些数据类型都不起作用。
declare @certificate nvarchar(200)
set @certificate = 'ITManagerCertificate'
begin transaction
use DBwork
-- remove signature from stored procedure
drop signature from Report_Manager
by certificate @certificate
-- drop certificate
--DROP CERTIFICATE @certificate
if @@ERROR > 0
begin
rollback transaction
end
else begin
commit transaction
end
答案 0 :(得分:1)
试试这个
declare @certificate nvarchar(200)
declare @sql nvarchar(1000)
set @certificate = N'ITManagerCertificate'
begin transaction
use DBwork
--Remove Signature from Store procedure
set @sql= N'drop signature from Report_Manager
by certificate '+ @certificate
execute sp_executesql @sql
--Drop certificate
--DROP CERTIFICATE @certificate
if @@ERROR > 0
begin
rollback transaction
end
else begin
commit transaction
end