0 votes
1 view
in SQL by (20.3k points)

Possible Duplicate:

SQL Server: Check if table exists

CREATE TABLE IF NOT EXISTS works on MySQL but fails with SQL Server 2008 R2. What is the equivalent syntax?

1 Answer

0 votes
by (40.3k points)

The below code will create a table called vehicle if the table does not already exist.

if not exists (select * from sysobjects where name='vehicle' and xtype='U')

    create table vehicle (

        Name varchar(64) not null

    )

go

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...