MS SQL Server
  Home arrow MS SQL Server arrow Retrieving SQL Server 2005 Database Info U...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Retrieving SQL Server 2005 Database Info Using SMO: Database Info, Table Info
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2006-02-07

    Table of Contents:
  • Retrieving SQL Server 2005 Database Info Using SMO: Database Info, Table Info
  • How do we retrieve basic info about all databases from a SQL Server instance using SMO?
  • How do we retrieve advanced info on all databases from a SQL Server instance using SMO?
  • How do we retrieve security info about all databases from a SQL Server instance using SMO?
  • How do we retrieve table information from a SQL Server database using SMO?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Retrieving SQL Server 2005 Database Info Using SMO: Database Info, Table Info


    (Page 1 of 5 )

    This article is the second in a series focusing on retrieving SQL Server 2005 information using SMO along with Visual Basic 2005 and Visual Studio 2005. With the basics covered in the previous article, this one goes right into technical information.
    A downloadable file for this article is available here.

    In this article, we mainly deal with the following types of information:

    • Basic database information
    • Advanced database information
    • Security information related to the database
    • Table information from a selected database

    Since I already explained some points about SMO, DMO and so on in my previous article, I shall dive right into the technical issues of using SMO. I also covered the concept of “working with SMO using Visual Studio 2005” in my previous article.  If you are new to SMO (or having any trouble working with a new Visual Studio 2005 solution), I strongly suggest you go through that article.

    Creating our own structure to hold basic database information

    The following function, “getStructDatabaseBasic” is one of the routines which is defined in “util.vb” (from the downloadable zip) to mainly hold basic database information.

    Public Function getStructDatabaseBasic() As DataTable

            Dim dt As New DataTable

            With dt.Columns

                .Add (New DataColumn ("Name"))

                .Add (New DataColumn ("Tables"))

                .Add (New DataColumn ("Views"))

                .Add (New DataColumn ("StoredProcedures"))

                .Add (New DataColumn ("UserDefinedDataTypes"))

                .Add (New DataColumn ("UserDefinedAggregates"))

                .Add (New DataColumn ("UserDefinedFunctions"))

                .Add (New DataColumn ("UserDefinedTypes"))

                .Add (New DataColumn ("Synonyms"))

                .Add (New DataColumn ("Triggers"))

            End With

            Return dt

        End Function

    It mainly creates a data table with a column structure on basic information, about a particular database existing in an SQL Server instance.  The column “Name” holds the database's name. The column “Tables” holds the number of tables in the database. The column “Views” hold the number of views in the database, and so on for the rest of the columns.

    More MS SQL Server Articles
    More By Jagadish Chaterjee


       · Hello guys, another contribution on the latest SQL Server 2005 SMO. Any doubts,...
     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway