Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 880319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:04:42+00:00 2026-05-15T12:04:42+00:00

I have a requirement in SQL Server 2008 in development database Only DBA’s (

  • 0

I have a requirement in SQL Server 2008 in development database

  1. Only DBA’s ( who are database owners ) can create, alter tables .
    Developer’s should not create or alter tables .
  2. Developers can create/alter Stored Procedure/User Defined functions
    in dbo schema and can execute SP/UDF.
  3. Developers should have SELECT,INSERT,DELETE,UPDATE on tables (
    tables in dbo schema

How to achieve this using GRANT statement


Found a sample solution from Google, but still have issue

CREATE LOGIN testdev WITH PASSWORD = 'sldkjlkjlkj 987kj//'

CREATE USER testdev

GRANT ALTER ON SCHEMA::dbo TO testdev
GRANT CREATE PROCEDURE TO testdev
GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo TO testdev

CREATE TABLE mysig (a int NOT NULL)
EXECUTE AS USER = 'testdev'
go

CREATE PROCEDURE slaskis AS PRINT 12
go

CREATE TABLE hoppsan(a int NOT NULL) -- FAILS!
go

INSERT mysig (a) VALUES(123)
go

REVERT
go

DROP PROCEDURE slaskis
DROP TABLE mysig
DROP USER testdev
DROP LOGIN testdev

The syntax above able to block developer to create table but cant block developer to use SSMS design and alter the table.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:04:43+00:00Added an answer on May 15, 2026 at 12:04 pm

    First of all I would use Roles instead of granting access directly to users. You may be already doing this, but I thought I would mention it.

    Okay, the problem here is granting ALTER to the Schema means that the grantee has ALTER access to all object types in the schema. Unfortunately, as far as I know, there is no way to grant permissions to specific object types so it is all or nothing. Conversely, you cannot grant ALTER to all objects and then deny ALTER to specific object types.

    The only way I have found to do this is to grant ALTER to the schema and then used a DDL Trigger to control what the role can do.

    Here is an updated version of your example demonstrating the principle:

    --** Create a Developer Role
    CREATE ROLE [Developer] AUTHORIZATION db_securityadmin;
    GO
    
    --** Grant view and execute on all SPs to Devloper
    --GRANT VIEW DEFINITION ON SCHEMA::dbo TO [Developer];
    GRANT CREATE PROCEDURE TO [Developer];
    GRANT SELECT, INSERT, UPDATE, DELETE, ALTER, EXECUTE, VIEW DEFINITION ON SCHEMA::dbo TO [Developer]
    
    --** Create user and login for testdev and add to the Developer role
    CREATE LOGIN testdev WITH PASSWORD = 'sldkjlkjlkj987kj' 
    CREATE USER testdev 
    EXEC sp_addrolemember @rolename = 'Developer', @membername = 'testdev';
    GO
    
    --** Create DDL trigger to deny drop and alter to the Developer role
    CREATE TRIGGER tr_db_DenyDropAlterTable_Dev 
    ON DATABASE 
    FOR DROP_TABLE, ALTER_TABLE 
    AS 
    BEGIN 
       IF IS_MEMBER('Developer') = 1 
       BEGIN 
           PRINT 'You are not authorized to alter or drop a table.'; 
           ROLLBACK TRAN; 
       END; 
    END; 
    GO
    
    --** Testing
    CREATE TABLE mysig (a int NOT NULL) ;
    
    EXECUTE AS USER = 'testdev'; 
    GO
    
    CREATE PROCEDURE slaskis AS PRINT 12; 
    GO
    
    CREATE TABLE hoppsan(a int NOT NULL); -- FAILS! 
    GO
    
    INSERT mysig (a) VALUES(123); 
    GO
    
    ALTER TABLE mysig ADD test INT; --** This will fail too
    GO 
    
    REVERT; 
    GO
    
    DROP PROCEDURE slaskis ;
    DROP TABLE mysig ;
    DROP USER testdev;
    DROP LOGIN testdev;
    DROP ROLE [Developer];
    DROP TRIGGER tr_db_DenyDropAlterTable_Dev on DATABASE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 435k
  • Answers 435k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer apply takes extra arguments between the function name and the… May 15, 2026 at 3:37 pm
  • Editorial Team
    Editorial Team added an answer You could try something like: library(plyr) max.col <- ncol(x) l_ply(seq(1,… May 15, 2026 at 3:37 pm
  • Editorial Team
    Editorial Team added an answer Instead of parsing as a DateTime you can parse it… May 15, 2026 at 3:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.