CREATE TABLE IF NOT EXISTS equivalent in SQL Server

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?


if not exists (select * from sysobjects where name='cars' and xtype='U')
    create table cars (
        Name varchar(64) not null
    )
go

如果表格不存在,上面将创建一个名为cars的表格。

链接地址: http://www.djcxy.com/p/94436.html

上一篇: 如果它不存在,C#SQL创建表

下一篇: 在SQL Server中CREATE TABLE IF NOT EXISTS等效