How can I check with SQL whether a table is already there or not?

A. Two methods :-

1. If object_id('tbl_name') is not null
<command>

2. if exists (select * from sysobjects where id = object_id('tbl_name') and sysstat & 0xf = 4)
<command>


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish