Results 1 to 5 of 5

Thread: How do you get a list of tables in a SQL Server DB?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    122

    Question How do you get a list of tables in a SQL Server DB?

    I have an ASP.NET application in which I need to connect to a specific SQL Server database and then list all of the tables contained within that database.

    How can I accomplish this?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Are you asking how to get the list of table names from sql server or how to show them on a web page (or both)

    If its the former then some options

    1) Every SQL Server database has system Views that you can use to get schema information. Just run a query on the view. Something like

    Code:
    Select TableName From Information_Schema.Tables 
    Where Table_Type = 'Base Table'
    2) Use ADOX.

    3) Access the sql server system tables directly.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    122
    Thanks.

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    or
    Code:
    SELECT * FROM sysobjects WHERE xtype = 'U'
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    FROM sysobjects WHERE xtype = 'U'
    Which is basically what the Information_Schema.Tables
    View executes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width