Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Staggerlee011/e92a049e2cc319b34698e6962e7ddcf7 to your computer and use it in GitHub Desktop.
Save Staggerlee011/e92a049e2cc319b34698e6962e7ddcf7 to your computer and use it in GitHub Desktop.
Common SQL Server CLR database settings
SELECT 'Pre Deployment Changes',name ,
is_trustworthy_on ,
SUSER_SNAME(owner_sid) AS [DBOwner]
FROM sys.databases
WHERE name = 'databaseName';
USE [master];
GO
ALTER DATABASE databaseName SET READ_WRITE WITH ROLLBACK IMMEDIATE;
GO
USE databaseName;
GO
EXEC sp_changedbowner 'sa';
GO
USE [master];
GO
ALTER DATABASE databaseName SET READ_ONLY WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE databaseName SET TRUSTWORTHY ON
GO
SELECT 'Post Deployment Changes', name ,
is_trustworthy_on ,
SUSER_SNAME(owner_sid) AS [DBOwner]
FROM sys.databases
WHERE name = 'databaseName';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment