Getting Table name

  • Hi

    How can I retrive list tables containing a word from a DB

    thanks
    sarat 🙂
    Curious about SQL

  • SELECT * FROM SYS.TABLES WHERE NAME LIKE '%string%'

    where string is word or table name to be serached

    Thanks,

    Amit Khanna

  • This should work:

    SELECT t.TABLE_NAME

    FROM INFORMATION_SCHEMA.TABLES t

    WHERE t.TABLE_NAME like '%some%'

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • one more query..

    select object_name(object_id), * from sys.objects where object_name(object_id) like 'sys%' and type = 'U'

    Abhijit - http://abhijitmore.wordpress.com

  • thanku 🙂

    thanks
    sarat 🙂
    Curious about SQL

  • There is clearly more than one way to skin a cat.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Hi Abhijit

    thanks for your reply...

    i am getting error while executing it ..

    ERROR: Invalid column name object_name and object_id

    thanks
    sarat 🙂
    Curious about SQL

  • Is guess you're using MSSQL2000...

    Try this one (it's a rewrite of Abhijit's code which was written for MSSQL2005):

    select object_name(id), * from sysobjects where object_name(id) like 'sys%' and type = 'U'

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply