use Charges
GO
----------删除-架构-角色-用户-----------------------------------------------
DROP SCHEMA [YXUSER]
GO
DROP SCHEMA [YX_VIEW]
GO
DROP USER [YXUSER]
GO
DROP ROLE [YX_VIEW]
GO
DROP LOGIN [YXUSER]
GO
DROP VIEW [V_YX_StudentChargeDetailItem]
GO
DROP VIEW [V_YX_ChargeItem]
GO
----------删除-架构-角色-用户-----------------------------------------------
DROP SCHEMA [YXUSER]
GO
DROP SCHEMA [YX_VIEW]
GO
DROP USER [YXUSER]
GO
DROP ROLE [YX_VIEW]
GO
DROP LOGIN [YXUSER]
GO
DROP VIEW [V_YX_StudentChargeDetailItem]
GO
DROP VIEW [V_YX_ChargeItem]
GO
--------------创建视图--------------------
create view b
as
select *
from a
GO
--建立登录用户:用户名,密码,数据库
exec sp_addlogin 'YXUSER','View123456','Charges'
--创建角色golden
exec sp_addrole 'YX_VIEW'
--授予角色golden 对数据库的select 权限
grant select on V_YX_ChargeItem to YX_VIEW
grant select on V_YX_StudentChargeDetailItem to YX_VIEW
--手动修改用户属性
EXEC sp_grantdbaccess 'YXUSER','YXUSER'
--添加newuser为角色newrole的成员
EXEC sp_addrolemember 'YX_VIEW','YXUSER'
go