How to check if the table exists in a database in SQL Server ?

To check if the table exists in a database in SQL Server , you can use the INFORMATION_SCHEMA view.

How to check if the table exists in a database in SQL Server ?

Here’s a query that gets the table details of the table “Department” in the AdventureWorks2014 database.

use AdventureWorks2014
GO
SELECT * 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_NAME = 'Department'


image

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this blog post, let’s learn about the error message “1459 – An error occurred while accessing the database mirroring...
In this blog post, let’s learn about the error message “7937 – Columnstore index has one or more missing column...