ITKeyword,专注技术干货聚合推荐

注册 | 登录

解决SQL Server 2008 Create Table Syntax Error

itPublisher 分享于

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

【阿里云】双十一活动,全年抄底价,限时3天!(老用户也有),
入口地址https://www.aliyun.com/1111/home

推荐:Sql Server 2008

创建函数: create function sector_pid(@id varchar(10)) returns @t_level table(id varchar(10)) as begin   insert into @t_level select @id   select @id 

I'm trying to do a simple create table in SQL Server 2008 and receiving a syntax error. I am using Microsoft SQL Server Management Studio > New Query

Here is the syntax:

CREATE TABLE Address
{
    AddressID int IDENTITY PRIMARY KEY,
    Street varchar(60) NULL,
    City varchar(50) NULL,
    State varchar(2) NULL,
    Zip varchar(10)NULL,
    Intersection1 varchar(60) NULL,
    Intersection2 varchar(60) NULL
}

And the error message:

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '{'.

The syntax appears to be accurate according to examples found online. What is the correct syntax for creating this table?

sql sql-server-2008
|
  this question
edited Apr 10 '13 at 6:54 marc_s 478k 101 926 1097 asked Apr 10 '13 at 6:30 Kairan 1,853 16 38 73      remove the last , please from Intersection2 varchar(60) NULL, –  Satya Apr 10 '13 at 6:31      @Satya in TSQL it is permitted. –  John Woo Apr 10 '13 at 6:32

 | 

3 Answers
3

解决方法

Use ( ) not { }

推荐:SQL Server 2008

΢

CREATE TABLE Address
(
    AddressID int IDENTITY PRIMARY KEY,
    Street varchar(60) NULL,
    City varchar(50) NULL,
    State varchar(2) NULL,
    Zip varchar(10)NULL,
    Intersection1 varchar(60) NULL,
    Intersection2 varchar(60) NULL,
)

|
  this answer
answered Apr 10 '13 at 6:32 John Woo 173k 31 302 355      Thanks a lot J W for teaching me this new thing –  Satya Apr 10 '13 at 6:38      but in MySQL it will generate syntax error :) hehe –  John Woo Apr 10 '13 at 6:39

 | 

You need to use () instead of {}

CREATE TABLE Address
(
    AddressID int IDENTITY PRIMARY KEY,
    Street varchar(60) NULL,
    City varchar(50) NULL,
    State varchar(2) NULL,
    Zip varchar(10)NULL,
    Intersection1 varchar(60) NULL,
    Intersection2 varchar(60) NULL
)

Also remove the last ,


|
  this answer
answered Apr 10 '13 at 6:34 Praveen Nambiar 3,240 1 12 25

 | 

Here is the syntax for creating table in Sql Server 2008:

 CREATE TABLE table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);

|
  this answer
answered May 17 '15 at 6:53 Gagan 49 3

 | 

推荐:SQL Server 2008 的安装

               SQL Server 2008简体中文企业版下载(SQL2008)   SQL Server 2008分为SQL Server 2008企业版、标准版、工作组版、Web版、开发者版、Express版、Co


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。