Back

Explore Courses Blog Tutorials Interview Questions
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.4k 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

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

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...