-
Notifications
You must be signed in to change notification settings - Fork 1
TableExists
Steven Liekens edited this page Aug 30, 2016
·
5 revisions
dbo.TableExists( 'name' )
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.
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.
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