惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
G
Google Developers Blog
D
Docker
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
I
InfoQ
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News

博客园 - Yuejun Sun

Office 365 Certificate Exam Resources Step By Step Guide to configure the “Replicating directory changes” for SharePoint 2010 and 2013 分享:Windows Azure 电子书 Sharepoint 2013配置失败:SQL 实例没有将“MaxDegree of Parallelism”设置为1 免费注册Sharepoint 2013 站点 巧用Discussions列表归档Outlook邮件 Special Offer: Watch Three In-Depth SQL Server Courses by SQLskills (FREE) Forward:Stale statistics on a newly created temporary table in a stored procedure can lead to poor performance How to: Database Service fails to start due to log full of model database 续:有关SQL SERVER分布统计的问题 有关SQL Server分布统计的问题 第三章:分析基本查询的文本和XML执行计划 续第二章:分析基本查询的图形执行计划--表连接 第二章:分析基本查询的图形执行计划 第一章:执行计划基本知识--文本执行计划和XML执行计划 第一章:执行计划基本知识--范例入门 第一章:执行计划基本知识 免费下载:Inside the SQL Server Query Optimizer(查询优化器内幕) 查询优化器如何使用统计—Part I
How to: Grant Permission on Development Severs as Batch f...
Yuejun Sun · 2013-04-17 · via 博客园 - Yuejun Sun

Recently I was asked how to grant permission on Dev servers for team members in SQL Server, actually, there are many way to do that, in this article, I will show you a simple way.

Firstly, you need to save the following sql script as SQL file, here I called it as ‘GrantRightsByUser.sql’

   1: USE [master]
   2: GO
   3: CREATE LOGIN $(login_user) FROM WINDOWS WITH DEFAULT_DATABASE=$(login_db)
   4: GO
   5: USE $(login_db)
   6: GO
   7: CREATE USER $(login_user) FOR LOGIN $(login_user)
   8: GO
   9: EXEC sp_addrolemember N'db_datareader', $(login_user)
  10: EXEC sp_addrolemember N'db_datawriter', $(login_user)
  11: EXEC sp_addrolemember N'db_owner',$(login_user)
  12: GO

Sencondly, you need to create another command file named ‘GrantRightsByUser.cmd’ with scripts below:

   1: start sqlcmd -S dev01 -E -i GrantRightsByUser.sql -vlogin_user="[contoso\Jack]" login_db="[db1]"
   2: start sqlcmd -S dev01 -E -i GrantRightsByUser.sql -vlogin_user="[contoso\Bob]" login_db="[db1]"
   3: start sqlcmd -S dev01 -E -i GrantRightsByUser.sql -vlogin_user="[contoso\John]" login_db="[db1]"

Note: dev01 is a SQL alias that direct to SQL instance, you can use cliconfg command to config sql alias.