Monday, 8 June 2009

Permissions in SQL Server - Users and Objects

USE master
GO
CREATE LOGIN JOHN WITH mailto:PASSWORD= - Create login
GO
USE REPORTSERVER - To create user in particular database. Please change the database to that particular database and then create user in that database.
GO
CREATE USER JOHN FOR LOGIN JOHN
GO
GRANT Select,Insert,Update on Batch to JOHN -- Grant permissions to particular
GO EXEC sp_helprotect @username='JOHN' - To see permissions in objects for the particular username
GO

REVOKE Select,Insert,Update on Batch to JOHN -- Revoke permissions to particular
GO
EXEC sp_helprotect @username='JOHN'
GO


DENY Select,Insert,Update on Batch to JOHN -- Deny permissions to particular user
GO
EXEC sp_helprotect @username='JOHN' -- Based on username
GO


EXEC sp_helprotect @name='Batch' -- Based on Object Name ie, table name etc
GO
EXEC sp_helprotect @GRANTorname='dbo' --It is the name of the principal that Granted permissions.
GO
EXEC sp_helprotect NULL, NULL, NULL, 's' --The following example lists all the statement permissions in the current database
GO
EXEC sp_helprotect NULL, NULL, NULL, 'o' -- Lists the object permissions



No comments:

Post a Comment