---
title: "SQL Server: Check if table exists"  
description: "SQL Server: Check if table exists"  
author: "Anonymous User"  
published: 2013-04-17  
updated: 2013-04-17  
canonical: https://www.mindstick.com/forum/772/sql-server-check-if-table-exists  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# SQL Server: Check if table exists

Hi Everyone!\
I would like this to be the ultimate [discussion](https://answers.mindstick.com/qa/44930/what-is-the-procedure-for-half-an-hour-discussion) on how to [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) a [table exists in SQL](https://www.mindstick.com/forum/159027/how-to-check-table-exists-in-sql-server) Server 2000/2005 using SQL Statement.\
When you Google for the answer, you get so many different answers. Is there an official/backward & forward compatible way of doing it?\
Here are two possible ways of doing it. Which is the [standard](https://www.mindstick.com/articles/23223/naming-convention-or-coding-standard)/best way of doing it?\
First way:\
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND TABLE_NAME='mytablename') SELECT 1 AS res ELSE SELECT 0 AS res;Second way:\
IF OBJECT_ID (N'".$table_name."', N'U') IS [NOT NULL](https://www.mindstick.com/interview/1933/what-is-not-null-constraint) SELECT 1 AS res ELSE SELECT 0 AS res;MySQL provides a nice SHOW TABLES LIKE '%[tablename](https://www.mindstick.com/forum/34722/how-to-get-label-text-from-table-reference-on-database-based-on-tablename-and-fieldname)%'; statement. I [am looking](https://answers.mindstick.com/qa/115463/i-am-looking-for-to-joining-the-mindstick-internship-program-how-to-apply) for something similar.\
Advance Thanks!\

## Replies

### Reply by AVADHESH PATEL

Hi Goti!\
You can used INFORMATION_SCHEMA to view table\
try as below\

```
IF (EXISTS (SELECT *                  FROM INFORMATION_SCHEMA.TABLES                  WHERE TABLE_SCHEMA = 'TheSchema'                  AND  TABLE_NAME = 'TheTable'))BEGIN    --Do StuffEND
```


---

Original Source: https://www.mindstick.com/forum/772/sql-server-check-if-table-exists

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
