sql server - Trouble using the Insert Into Syntax in SQL -



sql server - Trouble using the Insert Into Syntax in SQL -

on site (http://www.w3schools.com/sql/sql_insert.asp) says can utilize sql insert statement using syntax:

insert table_name values (value1,value2,value3,...);

i tried doing follows:

create table trade ( tradeid int primary key, -- define coolumn of type int, primary key can't null symbol varchar(20) not null, --define column of type varchar. not null indicates column must have value tradeamount decimal(15, 3), -- total digits 15, 3 or decimal points filled bit not null default(0), -- specify default of 0 on column ) go insert trade values('goog',10.235785,1)

however, error "column name or number of supplied values not match table definition" , unsure why case.

thanks

you didn't define first field autoincremental, if don't send it, table expecting 4 fields , sending 3.

this should work:

insert trade values(1,'goog',10.235785,1)

or can create table in way, adding identity(1,1) (for sql-server): http://www.w3schools.com/sql/sql_autoincrement.asp

create table trade ( tradeid int identity(1,1) primary key, -- define coolumn of type int, primary key can't null symbol varchar(20) not null, --define column of type varchar. not null indicates column must have value tradeamount decimal(15, 3), -- total digits 15, 3 or decimal points filled bit not null default(0), -- specify default of 0 on column ) go

sql sql-server

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -