<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sys.objects on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/sys.objects/</link><description>Recent content in Sys.objects on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Thu, 09 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/sys.objects/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Search Stored Procedure and View Text</title><link>https://www.sqlserver70.com/post/sql-server-search-stored-procedure-view-text/</link><pubDate>Thu, 09 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-search-stored-procedure-view-text/</guid><description>
&lt;h2 id="search-stored-procedure-and-view-definitions-in-sql-server"&gt;Search Stored Procedure and View Definitions in SQL Server&lt;/h2&gt;
&lt;p&gt;This script searches the text of stored procedures, views, functions, and triggers in the current database using &lt;code&gt;sys.sql_modules&lt;/code&gt;, returning any programmable object whose name or definition contains a given keyword.&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;Finding which stored procedures, views, or functions reference a specific table, column, or keyword is a routine DBA and developer task. It comes up when renaming a column, tracking down where a piece of business logic lives, auditing who calls a particular table, or investigating the impact of a schema change. SQL Server stores the source definition of every programmable object in &lt;code&gt;sys.sql_modules&lt;/code&gt;, making it straightforward to search across all object types in a single query. This script, adapted from the sqlserver-kit community collection by Ed Pollack and Konstantin Taranov, queries &lt;code&gt;sys.sql_modules&lt;/code&gt; joined to &lt;code&gt;sys.objects&lt;/code&gt; to search both object names and their full definitions, returning results with the object type, schema, and full source text.&lt;/p&gt;</description></item><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;h2 id="sql-server-object-level-permissions-script-generate-grant-statements-for-database-security"&gt;SQL Server Object-Level Permissions Script: Generate GRANT Statements for Database Security&lt;/h2&gt;
&lt;p&gt;Database security is a critical aspect of SQL Server administration, and managing permissions at the object level can be time-consuming when done manually. This SQL Server script automates the process of generating GRANT statements for all database objects, making it easier for database administrators to apply consistent permissions across their database schema.&lt;/p&gt;
&lt;h2 id="purpose-of-the-script"&gt;Purpose of the Script&lt;/h2&gt;
&lt;p&gt;This SQL Server script is designed to automatically generate GRANT permission statements for all user tables and stored procedures in a database. Instead of manually writing individual GRANT statements for each object, this script queries the system catalog to dynamically create the necessary permission commands for a specific database role called &lt;code&gt;SelectInsertUpdateDeleteExecSP&lt;/code&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;/p&gt;</description></item><item><title>Generate SQL Server Space Usage Commands for All User Tables</title><link>https://www.sqlserver70.com/post/sql-server-generate-space-usage-commands-for-all-tables/</link><pubDate>Thu, 07 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-generate-space-usage-commands-for-all-tables/</guid><description>
&lt;h2 id="generate-sql-server-space-usage-commands-for-all-user-tables"&gt;Generate SQL Server Space Usage Commands for All User Tables&lt;/h2&gt;
&lt;p&gt;Managing database storage is a critical aspect of SQL Server administration. Understanding how much space each table consumes helps database administrators make informed decisions about maintenance, archiving, and performance optimization. This article explores a powerful T-SQL script that automatically generates space usage commands for all user tables in your database.
&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;/p&gt;
&lt;h2 id="the-sql-server-code"&gt;The SQL Server Code&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;sp_spaceused &amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;go&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sysobjects&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;U&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;by&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;This T-SQL query serves as a time-saving utility for database administrators who need to quickly assess the space usage of all user tables in a SQL Server database. Instead of manually typing &lt;code&gt;sp_spaceused&lt;/code&gt; commands for each table, this script automatically generates the complete set of commands ready for execution.&lt;/p&gt;</description></item><item><title>Generate DBCC SHOWCONTIG Commands for All SQL Server Tables</title><link>https://www.sqlserver70.com/post/generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server/</link><pubDate>Fri, 01 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server/</guid><description>
&lt;h2 id="generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server"&gt;Generate DBCC SHOWCONTIG Commands for All User Tables in SQL Server&lt;/h2&gt;
&lt;p&gt;Database administrators frequently need to monitor table and index fragmentation to maintain optimal database performance. This SQL Server script provides an efficient way to generate DBCC SHOWCONTIG commands for all user tables in your database automatically.
&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;/p&gt;
&lt;h2 id="purpose"&gt;Purpose&lt;/h2&gt;
&lt;p&gt;The primary purpose of this script is to dynamically generate DBCC SHOWCONTIG commands for every user table in a SQL Server database. This eliminates the need to manually write individual commands for each table, saving time and ensuring comprehensive fragmentation analysis across all tables.&lt;/p&gt;</description></item></channel></rss>