0

我在尝试填充我的表格时遇到了很多错误。我不知道如何解决这个问题。我在脚本中生成了插入,但我很确定我输入值的方式不正确。如何插入多行而不必在每一行上都写 INSERT INTO?

/*INSERT INTO INVOICES*/
USE [Beta3]
GO

INSERT INTO [dbo].[INVOICE]
           ([INV_ID]
           ,[EMP_ID]
           ,[WAR_ID]
           ,[REP_ID]
           ,[FIN_ID]
           ,[INV_DATE]
           ,[INV_PRICE])
     VALUES
(5655,8,1,,3,'7/5/2000',75880);
(9749,1,1,,1,'11/26/2002',58881);
(9909,3,1,187,3,'12/27/2012',64859);
(4188,8,3,,2,'4/20/2009',16670);
(1265,6,2,155,2,'4/13/2007',20130);
(3874,7,2,,1,'3/25/2012',17809);
(9866,9,3,130,3,'2/27/2003',70183);
(7998,3,2,194,3,'4/11/2002',27622);
(5146,1,1,,1,'6/27/2002',58779);
(5283,4,3,,4,'1/24/2004',55112);
(9216,3,1,,1,'5/15/2003',59439);
(5881,9,2,,4,'7/8/2012',88095);
(8495,5,1,157,4,'8/20/2008',75160);
(8176,1,3,,2,'1/5/2006',19650);
(9723,4,1,124,4,'10/21/2006',59060);
(7132,2,3,192,2,'11/11/2008',26460);
(7947,2,2,150,1,'3/3/2006',55317);
(7458,8,2,,3,'4/27/2007',64009);
(8893,9,3,,4,'7/24/2012',40292);
(6683,7,1,,2,'7/24/2008',86020);
GO

/*INSERT INTO CAR_OWNERSHIP*/
USE [Beta3]
GO

INSERT INTO [dbo].[CAR_OWNERSHIP]
           ([VEH_ID]
           ,[CUS_ID]
           ,[INV_ID])
     VALUES
(1690,1,5655);
(1971,2,9749);
(1119,3,9909);
(1695,4,4188);
(1755,5,1265);
(1973,6,3874);
(1698,7,9866);
(1154,8,7998);
(1286,9,5146);
(1904,10,5283);
(1057,11,9216);
(1699,12,5881);
(1937,13,8495);
(1923,14,8176);
(1729,15,9723);
(1515,16,7132);
(1792,17,7947);
(1604,18,7458);
(1986,19,8893);
(1541,20,6683);
GO

/*INSERT INTO FINANCING*/
USE [Beta3]
GO

INSERT INTO [dbo].[FINANCING]
           ([FIN_ID]
           ,[FIN_OPTION]
           ,[FIN_RATE]
           ,[FIN_LENGHT])
     VALUES
(1,'Cash Payment ',0,0);
(2,'Don't pay for 12 months',1,12);
(3,'Don't pay for 24 months',1.5,24);
(4,'Don't pay for 36 months',2,36);
GO



/*INSERT INTO WARRANTY*/
USE [Beta3]
GO

INSERT INTO [dbo].[WARRANTY]
           ([WAR_ID]
           ,[WAR_TYPE]
           ,[WAR_TERM]
           ,[WAR_DESC])
     VALUES
(1,'BASIC COVERAGE',36,'COVERS ALL COMPONENTS');
(2,'POWER COVERAGE',60,'COVER ENGINE, TRANSMISSION, DRIVE SYSTEM');
(3,'SUPER POWER COVERAGE',75,'COVER ALL AND CORROSION PERFORATION');
GO




/*INSERT INTO CAR_BRAND*/
USE [Beta3]
GO

INSERT INTO [dbo].[CAR_BRAND]
           ([BRAND_ID]
           ,[BRAND_NAME]
           ,[COUNTRY])
     VALUES
(1,'Acura','Japan');
(2,'Audi','Germany');
(3,'BMW','Germany');
(4,'Chevrolet','United States');
(5,'Ford','United States');
(6,'Honda','Japan');
(7,'Lexus','Japan');
(8,'Mazda','Japan');
(9,'Nissan','Japan');
(10,'Toyota','Japan');
(10,'Toyota','Japan');
GO




/*INSERT INTO CAR_MODEL*/
USE [Beta3]
GO

INSERT INTO [dbo].[CAR_MODEL]
           ([BRAND_ID]
           ,[MODEL_ID]
           ,[MODEL_NAME])
     VALUES
(1,1,'ILX');
(2,1,'TSX');
(3,1,'TL');
(4,2,'A4');
(5,2,'R8');
(6,3,'3-Series');
(7,3,'5-Series');
(8,3,'7-Series');
(9,3,'X5');
(10,3,'M3');
(11,4,'Malibu Hybrid');
(12,4,'Malibu');
(13,4,'Corvette');
(14,4,'Volt');
(15,4,'Impala');
(16,5,'F-150');
(17,5,'F-450 Super Duty');
(18,5,'Explorer');
(19,5,'Mustang');
(20,6,'Civic');
(21,6,'Accord');
(22,6,'CR-V');
(23,6,'Odyssey');
(24,7,'GS 450h');
(25,7,'ES 350');
(26,8,'Mazda 3');
(27,8,'Mazda 6');
(28,8,'MX-5 Miata');
(29,8,'RX-8');
(30,9,'Pathfinder');
(31,9,'Quest');
(32,9,'Altima');
(33,9,'Altima Hybrid');
(34,10,'Prius');
(35,10,'Sienna');
GO


/*INSERT INTO CLASS*/
USE [Beta3]
GO

INSERT INTO [dbo].[CLASS]
           ([CLASS_ID]
           ,[CLASS_NAME])
     VALUES
(1,'Passenger Cars');
(2,'Luxury Cars');
(3,'Sports Cars');
(4,'SUVS');
(5,'Pickup Trucks');
(6,'Vans and Minivans');
(7,'Hybrids');
GO




/*INSERT INTO VEHICLE*/
USE [Beta3]
GO

INSERT INTO [dbo].[VEHICLE]
           ([MODEL_ID]
           ,[VEH_ID]
           ,[VEH_YEAR]
           ,[VEH_MILAGE]
           ,[VEH_DESC]
           ,[VEH_AC]
           ,[VEH_RADIO]
           ,[VEH_PRICE]
           ,[COLOUR_ID]
           ,[CLASS_ID]
           ,[SOURCE_ID])
     VALUES
(1,1690,2003,138347,'No','YES',8900,2,1,103);
(2,1971,2004,134511,'No','YES',12650,8,2,103);
(3,1480,2010,98990,'Yes','YES',25705,2,2,102);
(4,1221,2001,138184,'No','YES',12500,6,1,101);
(5,1119,2009,51392,'Yes','YES',84200,5,3,103);
(6,1277,2002,121758,'No','No',14900,10,1,101);
(7,1893,2004,143554,'No','YES',22900,8,2,101);
(8,1695,2004,128307,'No','YES',31900,10,2,102);
(9,1755,2000,117912,'No','No',10750,10,4,102);
(10,1973,2001,133168,'No','YES',29100,4,3,102);
(11,1358,2011,66841,'Yes','YES',30400,1,7,103);
(12,1698,2001,146123,'No','YES',8390,5,1,101);
(13,1805,2007,64851,'Yes','YES',49600,3,3,101);
(14,1984,2010,60741,'Yes','YES',30145,5,1,102);
(15,1427,2009,54884,'Yes','YES',19860,1,1,103);
(16,1819,2012,41334,'Yes','YES',42305,1,5,103);
(17,1683,2010,24765,'Yes','No',39395,10,5,101);
(18,1309,2001,133769,'No','No',12135,10,4,102);
(19,1154,2008,56756,'Yes','No',22200,5,3,102);
(20,1286,2011,59478,'Yes','YES',16690,10,1,103);
(21,1904,2005,58205,'No','YES',19680,6,1,101);
(22,1057,2001,107072,'No','YES',11495,2,4,103);
(23,1742,2011,97949,'Yes','YES',33825,6,6,102);
(24,1699,2007,41031,'Yes','No',38950,5,7,102);
(25,1514,2011,44000,'Yes','YES',36100,7,2,101);
(26,1937,2012,58946,'Yes','YES',24200,6,1,102);
(27,1923,2005,58269,'No','YES',20725,4,1,102);
(28,1729,2002,141345,'No','YES',10470,8,3,103);
(29,1856,2007,51130,'Yes','YES',26275,3,3,101);
(30,1515,2006,65543,'Yes','YES',22960,1,4,102);
(31,1792,2005,32758,'No','No',17990,7,6,103);
(32,1638,2011,35607,'Yes','YES',25500,10,1,103);
(33,1541,2012,62755,'Yes','YES',26800,4,7,101);
(34,1604,2010,43793,'Yes','No',24000,2,7,103);
(35,1986,2012,90622,'Yes','YES',40570,4,6,103);
GO




/*INSERT INTO COLOUR*/
USE [Beta3]
GO

INSERT INTO [dbo].[COLOUR]
           ([COL_ID]
           ,[COL_NAME])
     VALUES
(1,'White');
(2,'Silver');
(3,'Black');
(4,'Blue');
(5,'Grey');
(6,'Aqua');
(7,'Pink');
(8,'Red');
(9,'Yellow');
(10,'Purple');
GO




/*INSERT INTO SOURCE*/
USE [Beta3]
GO

INSERT INTO [dbo].[Source]
           ([SOURCE_ID]
           ,[SOURCE_NAME]
           ,[SOURCE_LOC]
           ,[SOURCE_TEL])
     VALUES
(101,'Individual Seller','613-828-5713');
(102,'Auction','613-538-5196');
(103,'Police Auction','613-661-5469');
(104,'Rental Car companies','613-580-5114');
(105,'Other Dealers','613-998-9948');
GO




/*INSERT INTO CUSTOMER*/
USE [Beta3]
GO

INSERT INTO [dbo].[CUSTOMER]
           ([CUS_ID]
           ,[CUS_FNAME]
           ,[CUS_LNAME]
           ,[CUS_PHONE]
           ,[LISCEN_NUM])
     VALUES
(1,'Bob','Smith','16131174040'623416);
(2,'Joe','Johnson','16132237628'734806);
(3,'Kim','Williams','16133120004'888884);
(4,'Matt','Jones','16132540773'812243);
(5,'Caleb','Brown','16135740247'180831);
(6,'Sam','Davis','16135012627'612910);
(7,'Jeremiah','Miller','16135721336'822848);
(8,'Ryan','Wilson','16139452481'366201);
(9,'Homer','Moore','16135996160'151727);
(10,'Brian','Taylor','16133555708'429716);
(11,'Peter','Anderson','16132816210'639311);
(12,'Sam','Thomas','16134814595'568958);
(13,'Luth','Jackson','16133658611'359456);
(14,'Serena','White','16132407151'881006);
(15,'Tina','Harris','16136286197'888579);
(16,'Karen','Martin','16139281238'531149);
(17,'James','Thompson','16131537652'680674);
(18,'Kevin','Garcia','16138508369'669945);
(19,'Luke','Martinez','16135832368'529603);
(20,'Kat','Robinson','16139675864'217919);
GO




/*INSERT INTO EMPLOYEE*/
USE [Beta3]
GO

INSERT INTO [dbo].[EMPLOYEE]
           ([EMP_LNAME]
           ,[EMP_FNAME]
           ,[EMP_PHONE]
           ,[EMP_ID]
           ,[EMP_SALARY])
     VALUES
('ANDERSON','MIKE',6135796468,1,63768)
('STEVENS','JERRY',6139175631,2,83420);
('ANDRES','GEORGE',6137909602,3,79999);
('ANDERSON','PAMELA',6131669903,4,88610);
('JAMESON','CARMELLA',6133630147,5,68822);
('BRYANT','MELISSA',6139705303,6,47886);
('TERRY','STACEY',6134478344,7,31576);
('DEVINE','KELLY',6137714828,8,67198);
('STARR','LEXI',6138903130,9,40494);
('JEREMY','STEVE',6134994912,10,67996);
('GATES','STEVE',6134994912,11,38415);
('SHAKUR','BIGGIE',6134994912,12,33269);
('LANDO','ANNAKIN',6134994912,13,39985);
('BLACK','TORY',6134994912,14,59870);
('ANNE','LISA',6134994912,15,44986);
GO




/*INSERT INTO ADMINS*/
INSERT INTO [dbo].[ADMINISTRATOR]
           ([EMP_ID]
           ,[QUALIFICATION])
     VALUES
(13,'MBA');
(14,’PHD’);
(15,’GRADUATE’);
GO

/*INSERT INTO SALESPERSON*/
USE [Beta3]
GO

INSERT INTO [dbo].[SALESPERSON]
           ([EMP_ID]
           ,[COMM_ID])
     VALUES
(1,5)
(2,4)
(3,2)
(4,2)
(5,3)
(6,2)
(7,1)
(8,4)
(9,5)
GO




/*INSERT INTO COMMISSION*/
USE [Beta3]
GO

INSERT INTO [dbo].[COMMISSION]
           ([COMM_ID]
           ,[COMM_Percentage])
     VALUES
(1,1);
(2,2.15);
(3,2.45);
(4,3);
(5,3.5);
GO




/*INSERT INTO MECHANIC*/
USE [Beta3]
GO

INSERT INTO [dbo].[MECHANIC]
           ([EMP_ID]
           ,[LICENSE])
     VALUES
('STARR','LEXI',6138903130,1,755000);
('JEREMY','STEVE',6134994912,1,755000);
('GATES','STEVE',6134994912,1,755000);
('SHAKUR','BIGGIE,6134994912,1,755000);
GO




/*INSERT INTO REPAIRS*/
USE [Beta3]
GO

INSERT INTO [dbo].[REPAIRS]
           ([REP_ID]
           ,[EMP_ID]
           ,[REPAIR_COST]
           ,[REPAIR_DESC])
     VALUES
(187,12,213.9,'CHANGE OIL');
(192,9,157.7,'FIX CALIBRATOR');
(130,11,169.5,'CHANGE WHIEELS ');
(194,11,142.9,'REPLACE HYPERFLEX');
(157,10,206.5,'BUFF OUT SCRATCHES');
(155,9,283.7,'FIX EXHAUST PIPE');
(124,11,120.1,'CHANGE WHEELS ');
(150,12,184.7,'REPLACE ENGINE');
GO




/*INSERT INTO REPAIR_TASK*/
USE [Beta3]
GO

INSERT INTO [dbo].[REPAIR_TASK]
           ([REP_ID]
           ,[PART_ID])
     VALUES
(187,'OV31');
(192,'KE18');
(130,'ZY71');
(194,'NP65');
(157,'SC51');
(155,'KU70');
(124,'TX58');
(150,'WG91');
GO




/*INSERT INTO PARTS*/
USE [Beta3]
GO

INSERT INTO [dbo].[PARTS]
           ([PART_ID]
           ,[VENDOR_ID]
           ,[PART_NAME]
           ,[PART_QTY])
     VALUES
('QD55','2JB33','WINTER TIRES',6);
('JN70','5XC38','SPRING TIRES',14);
('UM31','5XF87','ENGINE COVER',6);
('QB31','5XC38','A/C COMPRESSOR',8);
('BE70','6DS46','EXHAUST LEAD SHEILD',12);
('OV31','9FL62','EXHAUST PIPE',18);
('KE18','2JB33','POWER BRAKE ',18);
('ZY71','5XF87','DRIVE SHAFT',3);
('NP65','3TA60','EMERGENCY BRAKE',7);
('SC51','3TA60','RADIATOR CORE',4);
('KU70','4LY69','MASTER CYLINDER',10);
('TX58','3FC21','AIR PUMP',3);
('WG91','6DS46','FUEL CAP ',9);
('PN37','9FL62','SMOG PUMP',17);
GO




/*INSERT INTO VENDOR*/
USE [Beta3]
GO

INSERT INTO [dbo].[VENDOR]
           ([VENDOR_ID]
           ,[VEN_NAME]
           ,[VEN_CITY]
           ,[VEN_COUNTRY]
           ,[VEN_PHONE])
     VALUES
('9FL62','GOODYEAR','OHIO','CANADA','18005552356');
('3RN78','MICHELIN','QUEBEC','CANADA','18005559485');
('6DS46','FEDERAL-MOGUL','MICHIGAN','USA','18005557880');
('2JB33','DORMAN PRODUCTS','PENNSYLVANIA','USA','18005553675');
('4LY69','HOLLEY','KENTUCKY','USA','18005555094');
('5XC38','DANA HOLDING CORP','MAUMEE','USA','18005555286');
('5XF87','MAHLE GROUP','STUTTGART','GERMANY ','18005556669');
('3FC21','GKN GROUP ','WORCESTERSHIRE','ENGLAND','18005559991');
('3TA60','K&N ENGINEERING INC.','CALIFORNIA','USA','18005556846');
GO
4

3 回答 3

5

试试这个 ::

INSERT INTO [dbo].[INVOICE]
           ([INV_ID]
           ,[EMP_ID]
           ,[WAR_ID]
           ,[REP_ID]
           ,[FIN_ID]
           ,[INV_DATE]
           ,[INV_PRICE])
     VALUES
(5655,8,1,,3,'7/5/2000',75880),
(9749,1,1,,1,'11/26/2002',58881),
(9909,3,1,187,3,'12/27/2012',64859);
于 2012-11-15T10:05:47.247 回答
1

每行后都需要逗号而不是分号。

此外,您正在使用的表值构造函数语法有 1000 个值的限制(参考此处)。

只需生成插入内容,使每个语句中的行数不超过 1000 行INSERT INTO,并且使用逗号,就可以了。但是,如果您说出实际的错误是什么,这会有所帮助。

于 2012-11-15T10:53:22.543 回答
0

我已经为您的一张桌子编写了 inc 代码。请为其余表格相应地修改您的代码。我强烈建议您使用 SQL+ 来避免这种堆栈溢出。

公司代码:-

全部插入 [dbo].INVOICEVALUES (5655,8,1,,3,'7/5/2000',75880) 插入 [dbo].INVOICEVALUES (9749,1,1,,1,'11/26/2002 ',58881) INTO [dbo].INVOICEVALUES (9909,3,1,187,3,'12/27/2012',64859) INTO [dbo].INVOICEVALUES (4188,8,3,,2,'4/20/ 2009',16670) INTO [dbo].INVOICEVALUES (1265,6,2,155,2,'4/13/2007',20130) INTO [dbo].INVOICEVALUES (3874,7,2,,1,'3/25 /2012',17809) INTO [dbo].INVOICEVALUES (9866,9,3,130,3,'2/27/2003',70183) INTO [dbo].INVOICEVALUES (7998,3,2,194,3,'4/11 /2002',27622) INTO [dbo].INVOICEVALUES (5146,1,1,,1,'6/27/2002',58779) INTO [dbo].INVOICEVALUES (5283,4,3,,4,'1 /24/2004',55112) INTO [dbo].INVOICEVALUES (9216,3,1,,1,'5/15/2003',59439) INTO [dbo].INVOICEVALUES (5881,9,2,,4, '7/8/2012',88095) INTO [dbo].INVOICEVALUES (8495,5,1,157,4,'8/20/2008',75160) INTO [dbo].INVOICEVALUES (8176,1,3,,2,'1/5/2006',19650) INTO [dbo].INVOICEVALUES (9723,4,1,124,4, '10/21/2006',59060) INTO [dbo].INVOICEVALUES (7132,2,3,192,2,'11/11/2008',26460) INTO [dbo].INVOICEVALUES (7947,2,2,150,1, '3/3/2006',55317) INTO [dbo].INVOICEVALUES (7458,8,2,,3,'4/27/2007',64009) INTO [dbo].INVOICEVALUES (8893,9,3,, 4,'7/24/2012',40292) INTO [dbo].INVOICEVALUES (6683,7,1,,2,'7/24/2008',86020) SELECT * FROM dual;64009) INTO [dbo].INVOICEVALUES (8893,9,3,,4,'7/24/2012',40292) INTO [dbo].INVOICEVALUES (6683,7,1,,2,'7/24/2008 ',86020) SELECT * FROM dual;64009) INTO [dbo].INVOICEVALUES (8893,9,3,,4,'7/24/2012',40292) INTO [dbo].INVOICEVALUES (6683,7,1,,2,'7/24/2008 ',86020) SELECT * FROM dual;

问候, 拉詹

于 2012-11-15T10:50:43.200 回答