Skip to content

Instantly share code, notes, and snippets.

@jreypo
Last active January 2, 2016 03:29
Embed
What would you like to do?
SQL script to create the vCenter Chargeback database in Microsoft SQL Server
use [master]
GO
CREATE DATABASE [CBDB] ON PRIMARY
(NAME = N'CBDB', FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\CBDB.mdf' , SIZE = 200000KB , FILEGROWTH = 10% )
LOG ON
(NAME = N'CBDB_log', FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\CBDB.ldf' , SIZE = 20000KB , FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
GO
use [CBDB]
GO
ALTER DATABASE [CBDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [CBDB] SET ALLOW_SNAPSHOT_ISOLATION ON;
ALTER DATABASE [CBDB] SET READ_COMMITTED_SNAPSHOT ON WITH NO_WAIT;
ALTER DATABASE [CBDB] SET MULTI_USER;
GO
use [CBDB]
CREATE LOGIN [cbdbAdmin] WITH PASSWORD = 'VMwarerocks!', DEFAULT_DATABASE = [CBDB], DEFAULT_LANGUAGE =[us_english]
GO
ALTER LOGIN [cbdbAdmin] WITH CHECK_POLICY = OFF
GO
CREATE USER [cbdbAdmin] for LOGIN [cbdbAdmin]
GO
ALTER USER [cbdbAdmin] WITH DEFAULT_SCHEMA =[DBO]
GO
sp_addrolemember [db_owner], [cbdbAdmin]
GO
if not exists (SELECT name FROM sysusers WHERE issqlrole=1 AND name = 'cbAdminRole')
CREATE ROLE [cbAdminRole];
GRANT ALTER ON SCHEMA :: [DBO] to [cbAdminRole];
GRANT REFERENCES ON SCHEMA :: [DBO] to [cbAdminRole];
GRANT INSERT ON SCHEMA :: [DBO] to [cbAdminRole];
GRANT CREATE TABLE to [cbAdminRole];
GRANT CREATE VIEW to [cbAdminRole];
GRANT CREATE Procedure to [cbAdminRole];
GRANT ALTER ON SCHEMA :: [DBO] TO [cbAdminRole]
GRANT REFERENCES ON SCHEMA :: [DBO] TO [cbAdminRole]
GRANT INSERT ON SCHEMA :: [DBO] TO [cbAdminRole]
GRANT SELECT ON SCHEMA :: [DBO] TO [cbAdminRole]
GRANT DELETE ON SCHEMA :: [DBO] TO [cbAdminRole]
GRANT UPDATE ON SCHEMA :: [DBO] TO [cbAdminRole]
GRANT EXECUTE ON SCHEMA :: [DBO] TO [cbAdminRole]
GRANT ALTER ANY DATASPACE TO [cbAdminRole]
GRANT CREATE TABLE to [cbAdminRole]
GRANT CREATE VIEW to [cbAdminRole]
GRANT CREATE PROCEDURE to [cbAdminRole]
GRANT CREATE FUNCTION TO [cbAdminRole]
GO
sp_addrolemember [cbAdminRole] , [cbdbAdmin]
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment