TSQL: User-Defined Server Roles 70-462
Just a little TSQL for the User-Defined Server Roles exercise in the 70-462 training materials. Explanatory comments are included.
USE [master];
GO
-- Create server role
CREATE SERVER ROLE [Login_Manager];
GO
-- Assign permission to server role
GRANT ALTER ANY LOGIN TO [Login_Manager];
GO
-- Add login to role
ALTER SERVER ROLE [Login_Manager] ADD MEMBER [CONTSO\domain_group_b];
GO
-- Create server role
CREATE SERVER ROLE [Database_Creator];
GO
-- Allow role to create databases
GRANT CREATE ANY DATABASE TO [Database_Creator];
GO
-- Add login to this role
ALTER SERVER ROLE [Database_Creator] ADD MEMBER [CONTSO\domain_user_b];
GO