views:

60

answers:

1

I have created a database and some dbo.tables. Now I want to create a user that are can read and write to these tables, but not modify or drop. However I want this user to be able to create own tables and let him do what he want with these.

Is this possible? Could someone explain how this can be done?

+3  A: 

You would assign the user to db_datareader & db_datawriter roles for the dbo schema.

However, to allow the user to create and modify only new tables; you would have to create a different schema and assign, for example db_owner permissions to this schema.

You should be aware though, that doing this may create problems as you can have two tables with the same name under different schemas. So you should ensure that your queries always state the owner of the object.

e.g.

dbo.MyTable

CustomSchema.MyTable

UPDATE:

Ok, I think these are the steps you need to take:

  1. Create a new Database Role e.g db_ReportingRole and add the relevant user to this role.
  2. Create a new Schema e.g Reporting and make db_ReportingRole the owner of this schema.
  3. Assign the relevant CREATE, DROP, etc permissions to the db_ReportingRole
  4. Ensure that the same user added previously is in the db_datareader and db_datawriter roles for the dbo schema.

This should then allow you to have a user that can read and write to dbo schema but should be able to modify tables etc. However, because they in the db_ReportingRole they should have full access to modify, create, drop etc table in the Reporting schema. (Providing that you have assigned the correct permissions to the db_ReportingRole

I hope this works for you.

Barry
Thanks for your reply. How does I let the user use the new schema? Does I just change the default schema to the new schema or do I make the user owner of the new schema?
karl
When I'm creating the new schema and tries to add the permissions. I can't find the database role db_owner
karl
Hi Karl, this may help you when trying to assign permissions. http://msdn.microsoft.com/en-us/library/ms187940.aspx
Barry
You can either assign CREATE, SELECT permissions etc to the schema or create new database roles for the schema and assign permissions that way. Then add the user to the new database roles.
Barry
Sorry I don't get it right. I have created a new schema Schema_1. The owner for this schema is dbo. I have also Granted everything for a user User_1 in this schema, but when loging in as User_1 and trying to create a table it says the user doesn't have create table permission.
karl
When you create the table are using the fully qualified name?e.g. Create Table Schema_1.MyNewTable
Barry
I have updated my answer - hopefully this will help you out.
Barry