我试图从模板代码创建表。
此模板代码正在运行:
CREATE TABLE [dbo].[Table1]
(
[Field1] [int] NULL,
[Field2] [float] NULL
) ON [PRIMARY]
但是如果我把varchar(10):
CREATE TABLE [dbo].[Table1]
(
[Field1] [int] NULL,
[Field2] [varchar(10)] NULL
) ON [PRIMARY]
我收到错误:
Msg 2715, Level 16, State 7, Line 1
Column, parameter, or variable #2: Cannot find data type varchar(10).
答案 0 :(得分:27)
问题是方括号[]。您只需将varchar
放入括号:[varchar](10)
代码:
CREATE TABLE [dbo].[Table1]
(
[Field1] [int] NULL,
[Field2] [varchar](10) NULL
) ON [PRIMARY]
或者您也可以删除括号:
CREATE TABLE [dbo].[Table1]
(
[Field1] int NULL,
[Field2] varchar(10) NULL
) ON [PRIMARY]