Solved

MSSQL administration

Posted on 2004-10-28
458 Views
Last Modified: 2008-03-06
MSSQL administration

Summary:
Need a way to get a summary dashboard view of various table stats in MSSQL.

Details:
For example comparing against - MySql + phpmyadmin -
gives a nice overview of database stats.
For each table - rowcounts, bytes, etc.
What is a good way to get similar dashboard stats for MSSQL database?
I found sp_databases and sp_help
I was going to start wrinting something to pull stuff from dbo.sysobjects,
but I believe there may be solutions out there already.

Looking for good advice.
0
Question by:weinerk
    4 Comments
     
    LVL 8

    Expert Comment

    by:SashP
    Hi weinerk

    sp_spaceused [table name]

    will give you the results that that you are looking for

    Cheers Sash
    0
     
    LVL 8

    Accepted Solution

    by:
    weinerk,

    By definition, sp_spaceused only accepts a single object as a parameter.But in this case you can use the undocumented call sp_MSforeachtable as in:
    EXEC sp_MSforeachtable 'sp_spaceused ''?'''
    Or an alternative approach would be to write a cursor to loop through the number of tables and execute the sp_spaceused against each.

    You can also store the info in a table for later analysis as illustrated in this example...

    CREATE TABLE #TemptableforspaceUsed
    (name SYSNAME,
    rows INT,
    reserved VARCHAR(10),
    data VARCHAR(10),
    index_size VARCHAR(10),
    unused VARCHAR(10))
     
    INSERT #TemptableforspaceUsed
    EXEC sp_MSforeachtable 'sp_spaceused ''?'''

    select * from #TemptableforspaceUsed
    0
     
    LVL 1

    Author Comment

    by:weinerk
    Thanks, once I got that I found this:
    http://www.tkdinesh.com/faq/ans/spsumult.html

    Q:Can the stored procedure sp_spaceused be used on multiple tables at a time?

    A:By definition, sp_spaceused only accepts a single object as a parameter.But in this case you can use the undocumented call sp_MSforeachtable as in:
    EXEC sp_MSforeachtable 'sp_spaceused ''?'''
    Or an alternative approach would be to write a cursor to loop through the number of tables and execute the sp_spaceused against each.

    You can also store the info.in a table for later analysis as illustrated in this example...

    CREATE TABLE #TemptableforspaceUsed
    (name SYSNAME,
    rows INT,
    reserved VARCHAR(10),
    data VARCHAR(10),
    index_size VARCHAR(10),
    unused VARCHAR(10))
    GO
    INSERT #TemptableforspaceUsed
    EXEC sp_MSforeachtable 'sp_spaceused ''?'''

    0
     
    LVL 1

    Author Comment

    by:weinerk
    Funny I found the same page :-)))))
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    SQL Server Side Trace is a technique of Profiling SQL Server Events Silently (i.e without Using the Profiling Tool). Running a visual tool in production increases overhead, but we can develop server side Trace using Sql Server Profiler itself. We…
    I recently came across an interesting Question In EE (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/Q_27070749.html?cid=1135#a35876665) and was puzzled about how to achieve that using SSIS out of the box tasks, which was i…
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Via a live example, show how to shrink a transaction log file down to a reasonable size.

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now