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

推荐订阅源

博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
爱范儿
爱范儿
月光博客
月光博客
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
T
Tailwind CSS Blog
美团技术团队
D
Docker
V
Visual Studio Blog
Martin Fowler
Martin Fowler
博客园 - 聂微东
The Cloudflare Blog

博客园 - 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.