ronmichael
1/21/2013 - 12:15 AM

Add a certificate to a stored procedure in MSSQL

Add a certificate to a stored procedure in MSSQL

-- in this case we're giving the cert permission to alter the schema
-- (maybe explicitly disably identify and insert something into an identity column)

-- set up cert with permission to alter schema...
CREATE MASTER KEY ENCRYPTION BY password = '**opensesame**';
CREATE CERTIFICATE SchemaCert WITH SUBJECT = 'Schema user Certificate'
CREATE USER SchemaCertUser FROM CERTIFICATE SchemaCert
GRANT ALTER ANY SCHEMA TO SchemaCertUser

-- run or rerun the following line whenever you alter procedure,
-- to give procedure permission to alter schema
ADD SIGNATURE TO [procedurename] BY CERTIFICATE SchemaCert
GO