MS SQL Server
  Home arrow MS SQL Server arrow Page 3 - A Primer on INFORMATION_SCHEMA Views in SQ...
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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

A Primer on INFORMATION_SCHEMA Views in SQL Server 2000
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 40
    2005-05-23

    Table of Contents:
  • A Primer on INFORMATION_SCHEMA Views in SQL Server 2000
  • High-level overview of all INFORMATION_SCHEMA views
  • Most commonly used queries on INFORMATION_SCHEMA views
  • Internals of INFORMATION_SCHEMA views
  • Summary

  • 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
     
     
    ADVERTISEMENT


    A Primer on INFORMATION_SCHEMA Views in SQL Server 2000 - Most commonly used queries on INFORMATION_SCHEMA views


    (Page 3 of 5 )

    The following queries may help application programmers to get the most out of INFORMATION_SCHEMA views in a practical way. You can execute these queries on any database of any SQL Server 2000 instance.

    The following command gives the list of tables available in the database:

    select table_name

    from information_schema.tables

    where table_type='BASE TABLE'

    The following command gives the list of columns of every table in the database, including their data types and widths. You can also use a WHERE clause, if you would like to deal with only one table.

    select table_name,column_name, data_type, character_maximum_length as width

    from information_schema.columns

    order by table_name,ordinal_position

    The following command gives the list of all views and their definitions from the database.

    select table_name as view_name, view_definition from information_schema.views

    The following command gives all the list stored procedures and their definitions (unless they are encrypted) available in the database. To get the list of stored functions just replace the word ‘PROCEDURE’ with ‘FUNCTION’.

    select routine_name, routine_definition

    from information_schema.routines

    where routine_type='PROCEDURE'

    The following command gives you all the foreign key constraints (relationships) together with their respective primary keys of parents.

    select constraint_name as 'foreign key', unique_constraint_name as 'parent primary key'

    from information_schema.referential_constraints

    The following gives you all the lists of parameters of every routine (stored procedure or stored function) along with their data types and widths.

    select specific_name as [routine name],parameter_name, data_type, character_maximum_length as [width]

    from information_schema.parameters

    order by specific_name,ordinal_position

    The above examples are just to help you understand how this works. You can also design more complicated queries by joining the INFORMATION_SCHEMA views together according to the requirements.

    More MS SQL Server Articles
    More By Jagadish Chaterjee


     

    MS SQL SERVER ARTICLES

    - Windows Server 2008 as a Workstation OS
    - An Overview of Windows Server 2008 R2
    - LINQ to MySQL, Oracle and PostgreSQL Provide...
    - 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





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek