Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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.7k 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

You can master these queries and become proficient in SQL queries by enrolling in an industry-recognized SQL certification

Related questions

Browse Categories

...