insert into …… select 错误?帮帮我。
日期:2006-10-03 荐:
insert into …… select 错误?帮帮我。1> use changjiushop;2> INSERT INTO dbo.[客户]3> (登陆名,密码,电子邮件,电话,手机,姓名,地址,邮编,问题,答案,注册时间)4> VALUES (select username,password,e_mail,phone,mobile,name,address,postcode,question,answer,ftime from orderuser);5> go消息 156,级别 15,状态 1,服务器 NCOWBOY,行 4在关键字 'select' 附近有语法错误。消息 170,级别 15,状态 1,服务器 NCOWBOY,行 4第 4 行: ')' 附近有语法错误。1>CREATE TABLE dbo.orderuser ( ID int NOT NULL, e_mail nvarchar(100) NULL, password nvarchar(20) NULL, address nvarchar(250) NULL, phone nvarchar(100) NULL, name nvarchar(50) NULL, postcode nvarchar(200) NULL, username nvarchar(50) NULL, question nvarchar(50) NULL, answer nvarchar(50) NULL, company nvarchar(50) NULL, userclass nvarchar(50) NULL, ftime nvarchar(50) NULL, xiaofei int NULL, mobile nvarchar(50) NULL)goCREATE TABLE dbo.客户 ( 编号 int IDENTITY, 登陆名 nvarchar(50) NOT NULL, 密码 nvarchar(200) NOT NULL, 电子邮件 nvarchar(100) NOT NULL, 电话 nvarchar(100) NOT NULL, 手机 nvarchar(50) NOT NULL, 姓名 nvarchar(50) NOT NULL, 性别 char(1) CONSTRAINT DF__客户__性别__32767D0B DEFAULT 'm' NULL, 地址 nvarchar(250) NOT NULL, 邮编 nvarchar(6) NOT NULL, 问题 nvarchar(50) NOT NULL, 答案 nvarchar(50) NOT NULL, 注册时间 datetime CONSTRAINT DF__客户__注册时间__308E3499 DEFAULT getdate() NOT NULL, CONSTRAINT PK__客户__345EC57D PRIMARY KEY CLUSTERED (编号) ON [PRIMARY], CONSTRAINT UQ__客户__3552E9B6 UNIQUE NONCLUSTERED (登陆名,电子邮件) ON [PRIMARY],CONSTRAINT CK__客户__电子邮件__36470DEF CHECK ([电子邮件] like '_%@%_.%_'),CONSTRAINT CK__客户__性别__382F5661 CHECK ([性别] = 'm' or [性别] = 'f'))go1> use changjiushop;2> INSERT INTO dbo.[客户]3> (登陆名,密码,电子邮件,电话,手机,姓名,地址,邮编,问题,答案,注册时间)4> select username,password,e_mail,phone,mobile,name,address,postcode,question,answer,ftime from orderuser);5> goINSERT INTO dbo.[客户](登陆名,密码,电子邮件,电话,手机,姓名,地址,邮编,问题,答案,注册时间)(select username,password,e_mail,phone,mobile,name,address,postcode,question,answer,ftime from orderuser);5> go它的結構是﹕insert into tablename (a,b,c)select a,b,c from othertable或insert into tablename(a,b,c) values('1','2','3')在這里假如a,b,c 都是字符型试试INSERT INTO dbo.[客户](登陆名,密码,电子邮件,电话,手机,姓名,地址,邮编,问题,答案,注册时间)select username,password,e_mail,phone,mobile,name,address,postcode,question,answer,ftime from orderuserUSE ChangjiuShopgoTRUNCATE TABLE dbo.[客户]goINSERT INTO dbo.[客户](登陆名,密码,电子邮件,电话,手机,姓名,地址,邮编,问题,答案,注册时间)select DISTINCT username,password,e_mail,phone,mobile,name,address,postcode,question,answer,ftime from orderusergoselect * from dbo.[客户]gook。上面的问题基本解决了。但是我不明白我错在什么对方呢。哪个大侠可以告诉我?上面有人说了嘛,Insert时要么insert into tablename (a,b,c)select a,b,c from othertable或者insert into tablename(a,b,c) values('1','2','3')up
标签: