<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Database Roles on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/database-roles/</link><description>Recent content in Database Roles on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Fri, 08 Aug 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/database-roles/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Object Permissions: Generate GRANT Statements</title><link>https://www.sqlserver70.com/post/sql-server-object-level-permissions-script-generate-grant-statements-for-database-security/</link><pubDate>Fri, 08 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-object-level-permissions-script-generate-grant-statements-for-database-security/</guid><description>
&lt;p&gt;Giving an application role read, write and execute rights on a database usually means one &lt;code&gt;GRANT&lt;/code&gt; per table per permission plus one per stored procedure, which runs to hundreds of statements on a mid-sized schema. The script below writes those statements for you from &lt;code&gt;sys.objects&lt;/code&gt;, schema-qualified and bracket-quoted, so they can be reviewed and then run as one batch.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;Setting up a new application role is the usual job-to-be-done here: a database role such as &lt;code&gt;SelectInsertUpdateDeleteExecSP&lt;/code&gt; needs &lt;code&gt;SELECT&lt;/code&gt;, &lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; on the user tables and &lt;code&gt;EXECUTE&lt;/code&gt; on the stored procedures, and nobody wants to type those by hand. Because the script only builds text, nothing changes until you copy its output into a query window and execute it, which makes it safe to run on production to see what it would do.&lt;/p&gt;</description></item></channel></rss>