sql server 创建user 只读账号
USE [master]
GO
/****** Object: Login [yonyoutest] Script Date: 2021/8/17 14:45:19 ******/
DROP LOGIN [yonyoutest]
GO
/* For security reasons the login is created disabled and with a random password. */
/****** Object: Login [yonyoutest] Script Date: 2021/8/17 14:45:19 ******/
CREATE LOGIN [yonyoutest] WITH PASSWORD=N'uPWWQ9e46IkV6JTbjSNub8P/CLBsrbgRwVc+Hpi27Qk='
, DEFAULT_DATABASE=[YonYouTestDB], DEFAULT_LANGUAGE=[简体中文], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
REVOKE VIEW ANY DATABASE TO [public]
USE [YonYouTestDB] --数据库
go
EXEC dbo.sp_changedbowner N'yonyoutest'
如下开启/撤销只读账户可访问存储过程
use 供应链
grant view definition to dbread --开启只读用户 dbread 查看脚本权限
Revoke view definition to dbread --撤销只读用户 dbread 查看脚本权限