我想在表格中插入以下信息,但它从以下代码中给出了以下错误:
Msg 109,Level 15,State 1,Line 1 INSERT语句中的列多于VALUES子句中指定的值。 VALUES子句中的值数必须与INSERT语句中指定的列数相匹配。
create table registration
(
id int identity primary key,
first_name varchar(100),
last_name varchar(100),
username varchar(100),
[password] varchar(100),
email varchar(100),
[address] varchar(100),
gender varchar(10),
dob date,
reg_date date,
country varchar(50),
city varchar(50),
[status] bit
)
select * from registration
insert into registration (first_name,last_name,username,password,email,[address],gender,dob,reg_date,country,city,status)
values ('Ali','Khan','alik','123','alikhan@gmail.com','Male','19930318','20170318','Pakistan','Karachi')
答案 0 :(得分:1)
错误非常清楚,您缺少值中的某些列。试试这个:
insert into registration (first_name,last_name,username,password,email,[address],gender,dob,reg_date,country,city,status)
values ('Ali','Khan','alik','123','alikhan@gmail.com','100 Sample Street Address', 'Male','19930318','20170318','Pakistan','Karachi', cast(1 as bit))
答案 1 :(得分:0)
查看您的查询:
Column Value you want to insert
----------- ------------------------
first_name 'Ali'
last_name 'Khan'
username 'alik'
password '123'
email 'alikhan@gmail.com'
[address] 'Male'
gender '19930318'
dob '20170318'
reg_date 'Pakistan'
country 'Karachi'
city
status
您缺少一些值。错误清楚地表明了这一点。