Solved

VMware vSphere 5.1 vCenter and SSO SQL scripts

Posted on 2013-02-06
1
1,221 Views
Last Modified: 2013-07-29
Hi Experts,

I am currently looking for a way of How to combined two SQL scripts into one, by doing this, will allow me to save time when deploying a SQL server database, rather than build it manually, below is the scripts:

use [master]

go

CREATE DATABASE [VCDB] ON PRIMARY

(NAME = N'vcdb', FILENAME = N'C:\VCDB.mdf' , SIZE = 3000KB , FILEGROWTH = 10% )

LOG ON

(NAME = N'vcdb_log', FILENAME = N'C:\VCDB.ldf' , SIZE = 1500KB , FILEGROWTH = 10%)

COLLATE SQL_Latin1_General_CP1_CI_AS

go

use VCDB

go

sp_addlogin @loginame=[vpxuser], @passwd=N'vpxuser', @defdb='VCDB', @deflanguage='us_english'

go

ALTER LOGIN [vpxuser] WITH CHECK_POLICY = OFF

go

CREATE USER [vpxuser] for LOGIN [vpxuser]

go

CREATE SCHEMA [VMW]

go

ALTER USER [vpxuser] WITH DEFAULT_SCHEMA =[VMW]

go

User should have DBO Privileges or VC_ADMIN_ROLE and VC_USER_ROLE database roles

sp_addrolemember @rolename = 'db_owner', @membername = 'vpxuser'
go


--------------------------------------------------------------------------------------------------------------------

-- PROJECT     IMS
-- MODEL       IDENTITY MANAGEMENT SERVICE
-- COMPANY     RSA, the Security Division of EMC
-- DATABASE    MSSQL

USE MASTER
GO

-------------------------------------------------------------------------------------
-- Create database
--
-- Using this script is not mandatory. The database can be created with
-- SQL Management Studio, ensuring that there are two tablespaces, named RSA_DATA
-- and RSA_INDEX, and that there are only alphanumeric characters in the database name.
--
-- Before running this script, customize the file paths (CHANGE ME) below.
-- 1. Decide on a folder to hold the database files (10 GB of space required).
-- For example, it can be the DATA folder of the SQL Server, usually
-- C:\Program Files\Microsoft SQL Server\MSSQL10_50.<instance name>\MSSQL\DATA
-- 2. Replace all 3 occurrences of C:\CHANGE ME with the path to the folder

-- The database name can also be customized, but it is forbidden to include
-- reserved keywords like database or any characters other than letters, numbers,
-- _, @ and #.

-- Advanced users can put the different files (RSA_DATA, RSA_INDEX and LOG)
-- on different storage devices to improve performance. RSA_INDEX is a small file which
-- is recommended to be stored on a fast device.
-- For more details, please refer to Microsoft documentation at http://technet.microsoft.com/en-us/library/ms143547.aspx
-------------------------------------------------------------------------------------
CREATE DATABASE RSA ON PRIMARY(
    NAME='RSA_DATA',
    FILENAME='C:\CHANGE ME\RSA_DATA.mdf',
    SIZE=10MB,
    MAXSIZE=UNLIMITED,
    FILEGROWTH=10%),
FILEGROUP RSA_INDEX(
    NAME='RSA_INDEX',
    FILENAME='C:\CHANGE ME\RSA_INDEX.ndf',
    SIZE=10MB,
    MAXSIZE=UNLIMITED,
    FILEGROWTH=10%)
LOG ON(
    NAME='translog',
    FILENAME='C:\CHANGE ME\translog.ldf',
    SIZE=10MB,
    MAXSIZE=UNLIMITED,
    FILEGROWTH=10% )
GO

-- Set recommended perform settings on the database
EXEC SP_DBOPTION 'RSA', 'autoshrink', true
GO
EXEC SP_DBOPTION 'RSA', 'trunc. log on chkpt.', true
GO

CHECKPOINT
GO

-------------------------------------------------------------------------------------
-- To drop the database, the commands is:
-------------------------------------------------------------------------------------
-- DROP DATABASE RSA

I have taken the original files from the VMware vSphere installation media and pasted them here, so again what I am looking for is to combined the two files into a single SQL script.

Please let me know if this is possible.

Thanks,
0
Comment
Question by:Islandr
1 Comment
 
LVL 42

Accepted Solution

by:
EugeneZ earned 250 total points
ID: 38862153
it is already 1 script: did you try to run it ? (just if you can adjust file location instead of C: drive)

 
use [master]

go

CREATE DATABASE [VCDB] ON PRIMARY

(NAME = N'vcdb', FILENAME = N'C:\VCDB.mdf' , SIZE = 3000KB , FILEGROWTH = 10% )

LOG ON

(NAME = N'vcdb_log', FILENAME = N'C:\VCDB.ldf' , SIZE = 1500KB , FILEGROWTH = 10%)

COLLATE SQL_Latin1_General_CP1_CI_AS

go

use VCDB

go

sp_addlogin @loginame=[vpxuser], @passwd=N'vpxuser', @defdb='VCDB', @deflanguage='us_english'

go

ALTER LOGIN [vpxuser] WITH CHECK_POLICY = OFF

go

CREATE USER [vpxuser] for LOGIN [vpxuser]

go

CREATE SCHEMA [VMW] 

go

ALTER USER [vpxuser] WITH DEFAULT_SCHEMA =[VMW]

go

User should have DBO Privileges or VC_ADMIN_ROLE and VC_USER_ROLE database roles

sp_addrolemember @rolename = 'db_owner', @membername = 'vpxuser'
go


--------------------------------------------------------------------------------------------------------------------

-- PROJECT     IMS
-- MODEL       IDENTITY MANAGEMENT SERVICE
-- COMPANY     RSA, the Security Division of EMC
-- DATABASE    MSSQL

USE MASTER
GO

-------------------------------------------------------------------------------------
-- Create database
--
-- Using this script is not mandatory. The database can be created with
-- SQL Management Studio, ensuring that there are two tablespaces, named RSA_DATA
-- and RSA_INDEX, and that there are only alphanumeric characters in the database name.
--
-- Before running this script, customize the file paths (CHANGE ME) below.
-- 1. Decide on a folder to hold the database files (10 GB of space required).
-- For example, it can be the DATA folder of the SQL Server, usually
-- C:\Program Files\Microsoft SQL Server\MSSQL10_50.<instance name>\MSSQL\DATA
-- 2. Replace all 3 occurrences of C:\CHANGE ME with the path to the folder

-- The database name can also be customized, but it is forbidden to include
-- reserved keywords like database or any characters other than letters, numbers,
-- _, @ and #.

-- Advanced users can put the different files (RSA_DATA, RSA_INDEX and LOG)
-- on different storage devices to improve performance. RSA_INDEX is a small file which
-- is recommended to be stored on a fast device.
-- For more details, please refer to Microsoft documentation at http://technet.microsoft.com/en-us/library/ms143547.aspx
-------------------------------------------------------------------------------------
CREATE DATABASE RSA ON PRIMARY(
    NAME='RSA_DATA',
    FILENAME='C:\CHANGE ME\RSA_DATA.mdf',
    SIZE=10MB,
    MAXSIZE=UNLIMITED,
    FILEGROWTH=10%),
FILEGROUP RSA_INDEX(
    NAME='RSA_INDEX',
    FILENAME='C:\CHANGE ME\RSA_INDEX.ndf',
    SIZE=10MB,
    MAXSIZE=UNLIMITED,
    FILEGROWTH=10%)
LOG ON(
    NAME='translog',
    FILENAME='C:\CHANGE ME\translog.ldf',
    SIZE=10MB,
    MAXSIZE=UNLIMITED,
    FILEGROWTH=10% )
GO

-- Set recommended perform settings on the database
EXEC SP_DBOPTION 'RSA', 'autoshrink', true
GO
EXEC SP_DBOPTION 'RSA', 'trunc. log on chkpt.', true
GO

CHECKPOINT
GO

-------------------------------------------------------------------------------------
-- To drop the database, the commands is:
-------------------------------------------------------------------------------------
-- DROP DATABASE RSA

Open in new window

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
The viewer will learn how to count occurrences of each item in an array.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now