使用以下查询获取错误

时间:2013-04-29 10:48:13

标签: sql sql-server

CREATE TABLE [PIPE](
ID double,
REV nvarchar(100),
SCHEDULE double 
RATING nvarchar(100) ,
MATERIAL nvarchar(100) ,
MEAS_UNITS nvarchar(100) ,
MANU_FACT nvarchar(100) ,
EC_CLASS_NAME nvarchar(100) ,
WEIGHT_DRY double ,
END_COND_1 nvarchar(100) ,
PIPE_OD_M double ,
PIPE_OD_R double ,
END_COND_2 nvarchar(100) ,
RUN_SIZE double ,
MAIN_SIZE double ,
MAT_GRADE nvarchar(100) ,
SHORT_DESC nvarchar(100) ,
LONG_DESCR nvarchar(100) ,
WALL_THICKNESS_1 double ,
PIECE_MARK nvarchar(100));

我收到以下错误,请提示“Msg 102,Level 15,State 1,Line 2 “,”附近的语法不正确。“

5 个答案:

答案 0 :(得分:1)

SCHEDULE double RATING nvarchar(100)

你在双重后忘记了一个逗号。

答案 1 :(得分:0)

试试这个:(你忘了','在SCHEDULE之后加倍)

CREATE TABLE [PIPE]( ID double, REV nvarchar(100), SCHEDULE double, RATING nvarchar(100) , MATERIAL nvarchar(100) , MEAS_UNITS nvarchar(100) , MANU_FACT nvarchar(100) , EC_CLASS_NAME nvarchar(100) , WEIGHT_DRY double , END_COND_1 nvarchar(100) , PIPE_OD_M double , PIPE_OD_R double , END_COND_2 nvarchar(100) , RUN_SIZE double , MAIN_SIZE double , MAT_GRADE nvarchar(100) , SHORT_DESC nvarchar(100) , LONG_DESCR nvarchar(100) , WALL_THICKNESS_1 double , PIECE_MARK nvarchar(100));

也将double改为float

CREATE TABLE PIPE
    ( 
    ID int,
    REV nvarchar(100),
    SCHEDULE1 float,
    RATING nvarchar(100),
    MATERIAL nvarchar(100),
    MEAS_UNITS nvarchar(100),
    MANU_FACT nvarchar(100),
    EC_CLASS_NAME nvarchar(100),
    WEIGHT_DRY float, 
    END_COND_1 nvarchar(100),
    PIPE_OD_M float,
    PIPE_OD_R float, 
    END_COND_2 nvarchar(100),
    RUN_SIZE float,
    MAIN_SIZE float,
    MAT_GRADE nvarchar(100),
    SHORT_DESC nvarchar(100),
    LONG_DESCR nvarchar(100),
    WALL_THICKNESS_1 float, 
    PIECE_MARK nvarchar(100))

答案 2 :(得分:0)

您错过了字段之间的逗号,请查看SQLFIDDLE

答案 3 :(得分:0)

SQL Server中没有double数据类型,如果需要近似数字,则需要使用floatreal。您还错过了schedulerating之间的逗号:

CREATE TABLE [PIPE](
  ID float,
  REV nvarchar(100),
  SCHEDULE float,
  RATING nvarchar(100) ,
  MATERIAL nvarchar(100) ,
  MEAS_UNITS nvarchar(100) ,
  MANU_FACT nvarchar(100) ,
  EC_CLASS_NAME nvarchar(100) ,
  WEIGHT_DRY float ,
  END_COND_1 nvarchar(100) ,
  PIPE_OD_M float ,
  PIPE_OD_R float ,
  END_COND_2 nvarchar(100) ,
  RUN_SIZE float ,
  MAIN_SIZE float ,
  MAT_GRADE nvarchar(100) ,
  SHORT_DESC nvarchar(100) ,
  LONG_DESCR nvarchar(100) ,
  WALL_THICKNESS_1 float ,
  PIECE_MARK nvarchar(100)
);

我的建议是考虑使用精确数字数据类型,例如decimalnumeric

答案 4 :(得分:0)

试试这个 -

CREATE TABLE dbo.[PIPE] 
(
        ID DECIMAL(18,2)
    ,   REV NVARCHAR(100)
    ,   SCHEDULE DECIMAL(18,2)
    ,   RATING NVARCHAR(100)
    ,   MATERIAL NVARCHAR(100)
    ,   MEAS_UNITS NVARCHAR(100)
    ,   MANU_FACT NVARCHAR(100)
    ,   EC_CLASS_NAME NVARCHAR(100)
    ,   WEIGHT_DRY DECIMAL(18,2)
    ,   END_COND_1 NVARCHAR(100)
    ,   PIPE_OD_M DECIMAL(18,2)
    ,   PIPE_OD_R DECIMAL(18,2)
    ,   END_COND_2 NVARCHAR(100)
    ,   RUN_SIZE DECIMAL(18,2)
    ,   MAIN_SIZE DECIMAL(18,2)
    ,   MAT_GRADE NVARCHAR(100)
    ,   SHORT_DESC NVARCHAR(100)
    ,   LONG_DESCR NVARCHAR(100)
    ,   WALL_THICKNESS_1 DECIMAL(18,2)
    ,   PIECE_MARK NVARCHAR(100)
);