简体   繁体   中英

SQL Compact Error 80040E14 with multiple Insert statement

I'm trying to execute this query on an SQL Compact DB with the SQL Lite Toolbox for Visual Studio 2015.

INSERT INTO [RadiatorRegistries] ([Brand], [Series], [Model], [Height], [Width], [Depth], [Whellbase], [Capacity], [Surface], [Q50], [Exp], [Typology], [Material], [Kc1], [Kc2], [KcR]) VALUES (N'Aermec', N'Climafon', N'33', 675, 1000, 140, 0, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 2001, CAST(1.30 AS Decimal(18, 2)), N'Termoconvettore', N'Alluminio', CAST(1.00 AS Decimal(18, 2)), CAST(1.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)))
INSERT INTO [RadiatorRegistries] ([Brand], [Series], [Model], [Height], [Width], [Depth], [Whellbase], [Capacity], [Surface], [Q50], [Exp], [Typology], [Material], [Kc1], [Kc2], [KcR]) VALUES (N'Aermec', N'Climafon', N'41', 675, 1200, 140, 0, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 1810, CAST(1.30 AS Decimal(18, 2)), N'Termoconvettore', N'Alluminio', CAST(1.00 AS Decimal(18, 2)), CAST(1.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)))

The returned error is:

[ Token line number = 2,Token line offset = 1,Token in error = INSERT ]
Error Code: 80040E14

If I remove the second line the INSERT is working fine, the problem is that I've to insert about 2500 rows and I can't manually do that. I've also already tried to add a semicolon at the end of each row.

Any suggestion?

Seperate each line with a GO:

INSERT INTO [RadiatorRegistries] ([Brand],
GO
INSERT INTO [RadiatorRegistries] ([Brand],
GO

One method is to use insert . . . select insert . . . select insert . . . select with union all :

INSERT INTO [RadiatorRegistries]([Brand], [Series], [Model], [Height], [Width], [Depth], [Whellbase], [Capacity], [Surface], [Q50], [Exp], [Typology], [Material], [Kc1], [Kc2], [KcR]) 
    SELECT N'Aermec', N'Climafon', N'33', 675, 1000, 140, 0, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 2001, CAST(1.30 AS Decimal(18, 2)), N'Termoconvettore', N'Alluminio', CAST(1.00 AS Decimal(18, 2)), CAST(1.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2))
    UNION ALL
    SELECT N'Aermec', N'Climafon', N'41', 675, 1200, 140, 0, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 1810, CAST(1.30 AS Decimal(18, 2)), N'Termoconvettore', N'Alluminio', CAST(1.00 AS Decimal(18, 2)), CAST(1.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM