开发者

Granting table level permissions in sql express 2005

开发者 https://www.devze.com 2023-02-14 05:26 出处:网络
I created a login to connect to SQL SERVER. create login bobLogin with password = \'bobpass\' , default_database = bobDB

I created a login to connect to SQL SERVER.

create login bobLogin with password = 'bobpass' , default_database = bobDB

but when i am connecting sql server using this, it does not connects? because it needs a user.

so i created a user:

create user bobDB_USER for login bobLogin

then i connected to sql server using bobLogin & tried to create table:

create table bobDbTable(eid int)

which gives permission denied error;

so i granted permission:

GRANT CREATE TABLE TO bobDB_USER 

then i again connected using bobLogin, & tried to create a table but it gave error:

The specified schema name "dbo" either does not exist or you do not have permission to use it.

why so? its creating the table in the dbo schema, thats why? so how do i 开发者_如何学运维grant him this permission ?

i dont want to create a new schema. is it necessary?


You would need to GRANT ALTER ON SCHEMA::dbo TO bobDB_USER to allow objects to be created in the dbo schema.

I would also use a Role too.

create role bobDB_ROLE
EXEC sp_addrolemember 'bobDB_ROLE', 'bobDB_USER'
GRANT ALTER ON SCHEMA::dbo TO bobDB_ROLE

However, you could addbobDB_USER into db_owner if it requires these rights

EXEC sp_addrolemember 'db_owner', 'bobDB_USER'

Note: end user permissions are quite different to admin type rights. If 'bobDB_USER' is an end user, then they should not be creating objects

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号