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.
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.