knowing existence of a table in a database

  • i am working on an application that requires me to know whether a particular table in a database has been already created. if it has not, it will create the table, but if the table has been created, the creation process should be bypassed.

  • hi, try something like :-

    if not exists (select 1 from INFORMATION_SCHEMA.TABLES

               where TABLE_NAME = '{table_name})

    begin

      create table {table_name} (columns ...)

    end

    Paul

     

  • Thanks Paul. I will try that out.

     

Viewing 3 posts - 1 through 2 (of 2 total)

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