Results 1 to 4 of 4

Thread: [RESOLVED] table exist or not

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Resolved [RESOLVED] table exist or not

    I am Working on SQL and I want to check if table exist in a database or not.
    and also how can i check is specific field exist in table or not
    Help plz
    Last edited by xor83; Oct 9th, 2006 at 01:34 AM.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: table exist or not

    I am assuming you are using SQL Server.

    To check a Table
    PHP Code:
    Select count([NAME]) From SYSOBJECTS Where [NAME] = 'myTABLENAME' 
    To check if a field exists in a Table
    PHP Code:
    Select Count(SYSCOLUMNS.[NAME]) From SYSCOLUMNS Inner Join SYSOBJECTS On SYSCOLUMNS.ID SYSOBJECTS.ID Where SYSOBJECTS.[NAME] = 'myTableName' And SYSCOLUMNS.[NAME] = 'ColumnName' 
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Re: table exist or not

    Thanx

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: table exist or not

    If you consider this resolved, would you please pull down the Thread Tools menu and click the Mark Thread Resolved menu item? That will let everyone know that you have your answer.

    Thank you.

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