Skip to content

TableExists

Steven Liekens edited this page Aug 30, 2016 · 5 revisions

Syntax

dbo.TableExists( 'name' )

Arguments

name
sysname, required
The name of a table, optionally qualified with a schema name. When a schema name is specified, only tables in that schema are searched.

Return Types

bit, null
A value indicating whether a table with the specified name and optional schema exists, or NULL if the format of name is invalid.

Usage Examples

IF dbo.TableExists('dbo.Products') = 0
BEGIN
    CREATE TABLE dbo.Products(Id int, Name nvarchar(max));
END
IF dbo.TableExists('Products') = 1
BEGIN
    DROP TABLE Products;
END
Clone this wiki locally