﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Administering / SQL Server 2005  / how to check the Schema Objects Details in Each Database using SP / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 20:01:23 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: how to check the Schema Objects Details in Each Database using SP</title><link>http://www.sqlservercentral.com/Forums/Topic484782-146-1.aspx</link><description>Hi,You may use these two ways:1) Build dynamic query:SET NOCOUNT ONDECLARE @db NVARCHAR (50), @sqlStr NVARCHAR(4000)DECLARE @tbl_dbs TABLE (dbName NVARCHAR(50))INSERT  @tbl_dbs SELECT Name from master.sys.databasesWHILE EXISTS (SELECT dbName FROM @tbl_dbs)BEGINSELECT TOP 1 @db = dbName, @sqlStr = 'INSERT ABC..YourTable (ObjectName, name,type,type_desc ) SELECT  schema_name(schema_id)as ObjectName, name,type,type_desc from ' + @db + '.sys.objectswhere schema_name(schema_id) &amp;lt;&amp;gt; ''dbo''and type in(''U'',''P'',''V'', ''FN'',''TF'',''IF'',''PK'',''UQ'')' FROM @tbl_dbsEXEC master.dbo.sp_executesql @sqlStrDELETE  FROM @tbl_dbsWHERE dbName = @dbEND2) Use undocumented stored procedure (which is not actually recommended):EXEC sp_MSforeachDB 'INSERT ABC..YourTable (ObjectName, name,type,type_desc ) SELECT  schema_name(schema_id)as ObjectName, name,type,type_desc from ?.sys.objectswhere schema_name(schema_id) &amp;lt;&amp;gt; ''dbo''and type in(''U'',''P'',''V'', ''FN'',''TF'',''IF'',''PK'',''UQ'')'</description><pubDate>Tue, 15 Apr 2008 19:40:28 GMT</pubDate><dc:creator>magasvs</dc:creator></item><item><title>how to check the Schema Objects Details in Each Database using SP</title><link>http://www.sqlservercentral.com/Forums/Topic484782-146-1.aspx</link><description>Also I would need couple of details ,could you help me---This is what I needed,1)Objects which do not belong to DBOThis is the query we are using to find outselect schema_name(schema_id)as ObjectName, name,type,type_desc from sys.objectswhere schema_name(schema_id) &amp;lt;&amp;gt; 'dbo'and type in('U','P','V', 'FN','TF','IF','PK','UQ')go2)Database users which do not have DBO as their default schemaSELECT *FROM sys.database_principalsWHERE [type] IN ('U','S')        AND ISNULL(default_schema_name,'')&amp;lt;&amp;gt;'dbo'We would like to create a report out of it and let a procedure run in every instance  on a daily basis.  The procedures should write the information into seperate tables in theOne of DB(Like ABC)databaseI need to have the Sp in one Database and it needs to check all the Database and fetch the details into separate tables as per the database nameCould you please help me</description><pubDate>Tue, 15 Apr 2008 00:26:55 GMT</pubDate><dc:creator>sps-554505</dc:creator></item></channel></rss>