Justin Cooney

Web Development Tips and Examples

  • A great way to review all of the Clustered and NonClustered Indexes set up for a particular database is to query the SQL Server system tables.

    The sys.tables table contains the full list of tables for your database, and the sys.indexes table contains the full list of indexes. Simply join the two on their object_id columns and you have all of the information you could ever want about your indexes at your fingertips.

    Without further ado, here is the query:

    USE  MyDatabase
    GO
    SELECT b.name,b.type_desc,a.name,a.type_desc,a.*
    FROM sys.indexes a
    INNER JOIN sys.tables b ON a.object_id=b.object_id
    WHERE a.type IN (1,2)

    This is great if you want to review the indexes for a particular database on your instance of SQL Server. However if you want to review all indexes in all of the databases on your instance of SQL Server, then you can do so by adding the above query to the system sp_msforeachdb stored procedure.

    The great thing about sp_msforeachdb is that it will loop through each database on your instance of SQL Server for you and execute your database-agnostic command on each.

    So in practice, you can change the database-specific query above to the following in order to review all indexes in all of the databases on your instance of SQL Server:

    sp_msforeachdb 'select "?" AS db, b.name,b.type_desc,a.name,a.type_desc,a.* 
    FROM [?].sys.indexes a
    INNER JOIN [?].sys.tables b ON a.object_id=b.object_id
    WHERE a.type IN (1,2)'

    Resources:

  • What is the best way to see the full properties of all of the Linked Servers in SQL Server in one go? A SQL query is naturally the best way using SQL Server’s system tables!

    UI-Based Solutions:

    • The properties view in the SSMS UI does not show sufficient information about the set-up and history of the linked server.
    • In the SSMS UI one can click on the facets option rather than the properties view, which shows slightly more data.
    • One can script the linked server, which will show the important set-up information, but is generally not very friendly to read.

    T-SQL Solutions:

    The most thorough (and easy) method to check  configuration information and modification information for a linked server is to query the system tables.

    To generate a summary report of the Linked Servers in SSMS, run the sp_linkedservers stored procedure: (more…)

  • TwentyFeet Social Media Metrics Aggregator
    TwentyFeet Social Media Metrics Aggregator

    For the past few weeks I have been trying out the free version of the online social media statistics reporting service provided by TwentyFeet. I like monitoring my social media statistics, and was quite happy when I came across this tool. I have tried quite a few tools, but I like the comprehensiveness and ease of use of TwentyFeet and would definitely suggest trying it out if you have not already done so.

    TwentyFeet provides free monitoring of one Twitter account and one Facebook profile. If you like the free version of the service and want to hook up more accounts, the site also offers metrics for YouTube, MySpace, bit.ly and Google Analytics on a paid-for basis. Some sites also suggest that they are planning to add support for WordPress, which I will be interested in trying out.

    The TwentyFeet UI is slick, modern, and straightforward to use. With my Twitter account hooked up they have been gathering statistics for me for the past few weeks. When I log into my dashboard I am able to see overview graphs of my followers (+/-), my mentions and retweets, replies and direct tweets, new followers and un-subscribers, and list subscriber and member numbers.

    (more…)