• I have backed into a DBA role from a development background an I wonder why there isn't more discussion of [ Microsoft specific I think] SMO object model that affords you the ability to get row count and size of table plus more C# version of this.

    Down side of this is it is outside the database [Using a database API though] and there is extremely little documentation more hacking around with it to find what is required unless someone knows of a good source[ The most that I have found is a book with three chapters on it that I have on order]

    Certainly having a TSQL script to pull up in a database is probably the norm for DBA's but there could be occasion to write an application or service that may do this on demand or check against a predefined thresh hold and report to you when records exceed a certain predefined number though once again this could be done with a DTS package too

    using System.Data.SqlClient;

    using Microsoft.SqlServer.Management;

    using Microsoft.SqlServer.Management.Common;

    using Microsoft.SqlServer.Server;

    using Microsoft.SqlServer.Management.Smo;

    con.ConnectionString = @ConnectStringSA;

    con.Open();

    ServerConnection conn = new ServerConnection(con);

    Server svr = new Server(conn);

    foreach (Table oTable in svr.Databases[@DBName].Tables)

    {

    string sRowCount = oTable.RowCount.ToString();

    string sDataSpace = oTable.DataSpaceUsed.ToString();

    \\Yada Yada ya

    }

    Has anyone else used SMO extensively?