How to check if the Table exists in a SQL Server Database

To check if the Table exists in a SQL Server Database, run the following code that checks the INFORMATION_SCHEMA.TABLES view:

IF EXISTS(
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'Schema_Name'
AND TABLE_NAME='Table_Name'
AND TABLE_TYPE ='BASE TABLE')
BEGIN
-- If the table exists, the code in this block will run.
PRINT 'The table exists!'
END

check_table_information_schema_tables

Read related articles:
How to check if the View exists in a SQL Server Database
How to check if the Column exists in a SQL Server Table
How to List all Tables in a SQL Server Database

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">