开发者

SQL Server 2005 - Create Database with permissions for another database

I am a complete SQL Server newbie but I have experience with Oracle and MySQL. I am using SQL Server Management Studio.

I have an existing database that I want to create views from but I want those views to reside in another database (schema?) which will be accessible by a separate user account that can connect via JDBC.

I can create the database easily enough, right click "Databases" and select "New Database". From there I am lost.

1) How do I grant select/update/delete permissions (to create and update views) on one database to the new database?

2) How do I c开发者_如何转开发reate a new user?

3) How do I grant permissions for users?

Thanks in advance.


Like Martin said you need a new schema not a database.

CREATE SCHEMA [SchemaName] AUTHORIZATION dbo;

Create your Views under the new schema name then,

CREATE LOGIN [LoginName] {FROM WINDOWS} (If you are using an AD Group)

USE [DatabaseName];

CREATE USER [LoginName/Username]; (They can be the same)

GRANT EXECUTE, SELECT, INSERT, DELETE, VIEW DEFINITION ON Schema::[NewSchemaName] TO [LoginName/Username];

If you want to have a Role the create the role under the database and make the UserName a member of the Role and grant the permissions to the role.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜