Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The Ultimate Table Searcher


The Ultimate Table Searcher

Author
Message
YeshuaAgapao
YeshuaAgapao
SSC Eights!
SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)

Group: General Forum Members
Points: 807 Visits: 211
Comments posted to this topic are about the item The Ultimate Table Searcher



gaurav-628507
gaurav-628507
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 38
Great article. It (along with other "Searcher" articles by Jesse) addresses one of the biggest problems faced by developers as to how to search metadata. One issue that I see here is that it is only for SQL Server 2005+ and will fail in SQL 2000 as it makes use of sys.schemas table which is introduced in SQL 2005.

I would also recommend readers to try out search functionality in Omega.MSSQL (http://omega.cerebrata.com/r=SSCC63929), a browser based SQL server explorer developed by my company. Essentially you can search for keywords in tables (including columns, keys, triggers, indexes), views, stored procedures and all other objects just by using a browser based interface.

Do check it out.

Thanks

Gaurav
http://omega.cerebrata.com
Douglas Osborne-456728
Douglas Osborne-456728
SSC-Enthusiastic
SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)

Group: General Forum Members
Points: 190 Visits: 327
Jesse,

Another great article.

You could make one little add to this - return the number of Indicies for the table by adding

COUNT( index_id ) As Indicies,

to your inner join where you create partitions.

Here is my ammended code to list all tables alphabetically:

SELECT sys.objects.name AS TableName,
partitions.Rows, partitions.SizeMB, partitions.Indicies, partitions.SizeMBIndexes, sys.schemas.name AS owner, sys.objects.object_id
INTO dbo.DDTables
FROM sys.objects
INNER JOIN sys.schemas ON sys.objects.schema_id=sys.schemas.schema_id
INNER JOIN (
SELECT object_id, SUM(row_count) AS Rows, count( index_id) As Indicies,
CONVERT(numeric(19,3), CONVERT(numeric(19,3), SUM(CASE WHEN index_id BETWEEN 0 AND 1 THEN in_row_reserved_page_count+lob_reserved_page_count+row_overflow_reserved_page_count ELSE 0 END))/CONVERT(numeric(19,3), 128)) AS SizeMB,
CONVERT(numeric(19,3), CONVERT(numeric(19,3), SUM(CASE WHEN index_id>1 THEN in_row_reserved_page_count+lob_reserved_page_count+row_overflow_reserved_page_count ELSE 0 END))/CONVERT(numeric(19,3), 128)) AS SizeMBIndexes
FROM sys.dm_db_partition_stats
GROUP BY object_id
) AS partitions ON sys.objects.object_id=partitions.object_id
WHERE sys.objects.type='u'
ORDER BY sys.objects.name


YeshuaAgapao
YeshuaAgapao
SSC Eights!
SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)SSC Eights! (807 reputation)

Group: General Forum Members
Points: 807 Visits: 211
I submitted 'The Ultimate Table Searcher Mk2' that adds PartitionCount, IndexCount, ColumnCount, TotalMaxColumnLength, HasPrimaryKey, and HasClusteredIndex.



Douglas Osborne-456728
Douglas Osborne-456728
SSC-Enthusiastic
SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)

Group: General Forum Members
Points: 190 Visits: 327
YeshuaAgapao ,

Good Deal - did you fix my mistake - count( index_id) As Indicies should be (COUNT( index_id ) - 1 ) As Indicies.

Best,
Doug
Douglas Osborne-456728
Douglas Osborne-456728
SSC-Enthusiastic
SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)SSC-Enthusiastic (190 reputation)

Group: General Forum Members
Points: 190 Visits: 327
Jesse,

Nice change to the program.

Doug
Iwas Bornready
Iwas Bornready
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11970 Visits: 885
Thanks for the script. You've got a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search