- Logins: Server level
- Users: Database level, mapped to server logins
- Schemas: Database level, authorized/owned by a user or another schema
- Roles: Database level, authorized/owned by a user or another role
- Permissions: Database level, permission like SELECT, DELETE, ALTER and so on for objects/schemas granted to users/roles
Let's take a closer look at each of these.
When you create a server in SQL Azure, it asks you to create a login at the same time. That login acts as the administrative login that has access to all the databases in that server. However, you might want to create other logins with less privileges. As of now, the SQL Azure portal doesn't have any UI to create these extra logins. So you'll need to resort to running T-SQL statements.
Note: All of the following procedure are done using the administrative login mentioned above.
Creating Logins
- CREATE LOGIN MyServerLogin WITH password='My#Password123'
- CREATE USER MyDatabaseUser FROM LOGIN MyServerLogin;
- EXEC sp_addrolemember 'db_datareader', 'MyDatabaseUser';
Creating custom roles
- -- Create the database role
- CREATE ROLE MyDBRole AUTHORIZATION [dbo]
- GO
Here in this example we are giving all possible permissions on the DBO schema. (All database objects belong to this schema normally. However, custom schemas can be very well created.)
- -- Grant access rights to a specific schema in the database
- GRANT
- ALTER,
- CONTROL,
- DELETE,
- EXECUTE,
- INSERT,
- REFERENCES,
- SELECT,
- TAKE OWNERSHIP,
- UPDATE,
- VIEW DEFINITION
- ON SCHEMA::dbo
- TO MyDbRole
- GO
- -- Add an existing user to the new role created
- EXEC sp_addrolemember 'MyDBRole', 'MyDBUser'
- GO
- -- Revoke access rights on a schema from a role
- DENY ALTER
- ON SCHEMA::dbo
- TO MyDbRole

Gowtham RajamanickamPosted May 18, 2015, 12:57 PM
informative..
Karthik Muthu KaruppanPosted May 4, 2015, 1:58 PM
Nice
Santhakumar MunuswamyPosted May 3, 2015, 11:43 PM
Thanks for nice article