I'm trying to create table from template code.
我正在尝试从模板代码创建表。
This template code is working:
此模板代码正在运行:
CREATE TABLE [dbo].[Table1]
(
[Field1] [int] NULL,
[Field2] [float] NULL
) ON [PRIMARY]
But if I put varchar(10):
但是如果我把varchar(10):
CREATE TABLE [dbo].[Table1]
(
[Field1] [int] NULL,
[Field2] [varchar(10)] NULL
) ON [PRIMARY]
I get error:
我收到错误:
Msg 2715, Level 16, State 7, Line 1
Column, parameter, or variable #2: Cannot find data type varchar(10).
1 个解决方案
#1
24
The problem are brackets []. You have to put only varchar
into brackets: [varchar](10)
问题是括号[]。你必须只将varchar放入括号:[varchar](10)
Code:
码:
CREATE TABLE [dbo].[Table1]
(
[Field1] [int] NULL,
[Field2] [varchar](10) NULL
) ON [PRIMARY]
Or you can also remove the brackets:
或者您也可以删除括号:
CREATE TABLE [dbo].[Table1]
(
[Field1] int NULL,
[Field2] varchar(10) NULL
) ON [PRIMARY]
#1
24
The problem are brackets []. You have to put only varchar
into brackets: [varchar](10)
问题是括号[]。你必须只将varchar放入括号:[varchar](10)
Code:
码:
CREATE TABLE [dbo].[Table1]
(
[Field1] [int] NULL,
[Field2] [varchar](10) NULL
) ON [PRIMARY]
Or you can also remove the brackets:
或者您也可以删除括号:
CREATE TABLE [dbo].[Table1]
(
[Field1] int NULL,
[Field2] varchar(10) NULL
) ON [PRIMARY]