Column, parameter, or variable #10: Cannot find da

2020-06-30 05:01发布

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):

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条回答
一夜七次
2楼-- · 2020-06-30 05:42

The problem are brackets []. You have to put only varchar into brackets: [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]
查看更多
登录 后发表回答