Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column, parameter, or variable #10: Cannot find data type

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). 
like image 470
hoggar Avatar asked Oct 26 '14 22:10

hoggar


People also ask

What is data type in column?

The data type of a column defines what value the column can hold: integer, character, money, date and time, binary, and so on.

Which data type can store variable length in a column?

In practical scenarios, varchar(n) is used to store variable length value as a string, here 'n' denotes the string length in bytes and it can go up to 8000 characters. Now, let's proceed further and see how we can store SQL varchar data with a string length into the column of a SQL table.


1 Answers

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] 
like image 138
hoggar Avatar answered Oct 11 '22 05:10

hoggar