SQL Server Articles, SQL Server Tips, SQL Server Tutorials, SQL Server Tuning, SQL Server DBA, SQL Server Basics, Training, etc - MyTechMantra.com

How to Configure a Contained Database Feature in SQL Server

Click here to read How to Configure a Contained Database Feature in SQL Server” article from the beginning.

How to Create a Contained Database in SQL Server 2012 and Higher Versions

Once Contained Database feature is enabled successfully at SQL Server 2012 Instance Level then the next step will be to create a contained database.

Step 1. Connect to SQL Server 2012 Instance

Step 2. In Object Explorer, right click Databases and choose New Databases…. option from the drop down menu

Step 3. In General Page enter the name of Contained Database as ContainedDatabaseSQL2012 and click on Options page on the left side pane of New Database window

Step 4. In Options page choose Containment Type as “PARTIAL” from the drop down as shown in the below snippet.

Creating Contained Database Using SSMS

Step 5. Finally click OK to create your first Contained Database in SQL Server 2012.

How to Create a Contained Database in SQL Server Using T-SQL Query

Execute the below mentioned T-SQL query to create a Contained Database.

CREATE DATABASE [ContainedDatabaseSQL2012]
CONTAINMENT = PARTIAL
ON PRIMARY
(
NAME = N'ContainedDatabaseSQL2012',
FILENAME = N'D:\MSSQL\DATA\ContainedDatabaseSQL2012.mdf',
SIZE = 3072KB,
FILEGROWTH = 1024KB
)
LOG ON
(
NAME = N'ContainedDatabaseSQL2012_log',
FILENAME = N'D:\MSSQL\DATA\ContainedDatabaseSQL2012_log.ldf',
SIZE = 1024KB,
FILEGROWTH = 10%
)
GO

Click the below Number Buttons to continue reading the rest of the article.

Chetna Bhalla

Chetna Bhalla

LESS ME MORE WE

Chetna Bhalla, the founder of MyTechMantra.com, believes that by sharing knowledge and building communities, we can make this world a better place to live in. Chetna is a Graduate in Social Sciences and a Masters in Human Resources and International Business. She is an alumnus of Vignana Jyothi Institute of Management, Hyderabad, India. After graduation, Chetna founded this website, which has since then become quite a favorite in the tech world. Her vision is to make this website the favorite place for seeking information on Databases and other Information Technology areas. She believes that companies which can organize and deploy their data to frame strategies are going to have a competitive edge over others. Her interest areas include Microsoft SQL Server and overall Database Management. Apart from her work, Chetna enjoys spending time with her friends, painting, gardening, playing the violin, and spending time with her son.

Add comment

Newsletter Signup! Join 15,000+ Professionals




Be Social! Like & Follow Us...

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Advertisement