Skip to main content
Inspiring
November 10, 2008
Answered

How to check on database table existence?

  • November 10, 2008
  • 2 replies
  • 475 views
I want to check if a certain database table exists, if so run code / display message etc.
so not if the table holds data or not, but if it is in the database.

Any idea's?

Thanks!
    This topic has been closed for replies.
    Correct answer Dan_Bracuk
    figure out a way to query the system tables, assuming you have permission to do so. The details are db specific.

    2 replies

    November 14, 2008
    if it's Sybase and this might work in MS SQL as well

    select count(name) as tablecount from thedatabasename..sysobjects where type = 'U' and name = 'thetablename'
    Dan_BracukCorrect answer
    Inspiring
    November 10, 2008
    figure out a way to query the system tables, assuming you have permission to do so. The details are db specific.