SQL Server 2012 – How to enable contained database authentication

— Enable contained database authentication

sp_configure ‘contained database authentication’, 1;
GO
RECONFIGURE
GO

— Create Database with User & Password stored in the database itself.

CREATE DATABASE [MyConAuthDB] CONTAINMENT=PARTIAL
GO

USE [MyConAuthDB]
GO

CREATE TABLE baseTable(id int, [name] varchar (255))
GO

CREATE USER testuser1 WITH PASSWORD = N’password’, DEFAULT_SCHEMA=[dbo]
GO

EXEC sp_addrolemember’db_owner’, ‘testuser1’
GO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s