Skip to content

Instantly share code, notes, and snippets.

@ronmichael
Created January 21, 2013 00:15
Show Gist options
  • Save ronmichael/4582751 to your computer and use it in GitHub Desktop.
Save ronmichael/4582751 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment