One thought on “I need a query to check if a table exists in SQL Server.

  1. The best way to create a sql server query like this is to use an INFORMATION_SCHEMA view. This is a standard view across many different databases (Sql server, MySql) and rarely changes from version to version.
    To check if a table exists, you can use the following code:

    IF (EXISTS (SELECT *
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = 'Schema Name'
    AND TABLE_NAME = 'Table Name'))
    BEGIN
    --Do Stuff
    END

Comments are closed.