GRANT assigns specific database or object privileges to users or roles in SQL Server.
GRANT explicitly gives a principal (user, role, or application login) the right to perform specific actions—such as SELECT, INSERT, UPDATE, or EXECUTE—on a database, schema, or object. Without GRANT, the principal cannot use the secured resource.
GRANT follows the pattern: GRANT permission_list ON securable TO principal [WITH GRANT OPTION]. You can grant on objects (tables, views, procedures), schemas, or the entire database. Optional WITH GRANT OPTION lets the recipient pass the permission to others.
Typical ecommerce privileges include SELECT on Products for catalogue widgets, INSERT on Orders for web-checkout processes, and EXECUTE on stored procedures that calculate discounts or replenish stock.
To let the reporting role read only the Products table:
GRANT SELECT ON dbo.Products TO reporting_role;This grants read-only access without exposing other tables.
Comma-separate the permissions:
GRANT SELECT, UPDATE ON dbo.Products TO inventory_app;The inventory_app login can query and update product rows but cannot delete them.
Add WITH GRANT OPTION:
GRANT SELECT ON dbo.Customers TO senior_analyst WITH GRANT OPTION;The senior_analyst can now share that SELECT right with junior analysts.
Grant the smallest privilege set required (principle of least privilege). Prefer roles over individual users. Revoke permissions when a feature or team no longer needs them. Document every GRANT in version control.
A frequent error is granting on the wrong schema (e.g., forgetting dbo.). Another is forgetting to add column-level security when sensitive data appears in wide tables.
Yes. Use GRANT SELECT ON SCHEMA::sales TO analyst_role; This covers all current and future tables in the sales schema.
Use REVOKE to remove granted rights or DENY to explicitly block them.
No. DENY always overrides GRANT. If a principal is denied a permission, no GRANT can bypass it without first removing the DENY.
Yes. If executed inside a transaction, a GRANT can be rolled back just like data-modifying statements.
Yes. Query sys.database_permissions joined with sys.objects to generate scripts, or use SSMS "Script As".