Created
March 8, 2017 15:03
-
-
Save Staggerlee011/e92a049e2cc319b34698e6962e7ddcf7 to your computer and use it in GitHub Desktop.
Common SQL Server CLR database settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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