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

推荐订阅源

博客园 - 三生石上(FineUI控件)
月光博客
月光博客
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Vercel News
Vercel News
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
Jina AI
Jina AI
Y
Y Combinator Blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI

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