Select all tables in a database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sridhar21
    New Member
    • Feb 2007
    • 26

    Select all tables in a database

    hi to all


    i am sridhar


    My question is:

    To select all tables in a database is

    select name from sysobjects where type='U'

    But want to mension the database name in the query itself


    select .............. where database = 'mydatabas'"

    i need query for this


    thanks
  • Purple
    Recognized Expert Contributor
    • May 2007
    • 404

    #2
    Hi,

    how about

    Code:
    SELECT     name AS Expr1, xtype AS Expr2
    FROM         mydatabas.dbo.sysobjects
    WHERE     (xtype = 'U')
    xtype of 'S' if you want system tables

    dbo is the owner

    Purple
    Last edited by Purple; Jun 14 '07, 03:30 PM. Reason: .

    Comment

    Working...