Menu

#859 [MS SQL] Import CSV

4.8.1
closed-fixed
nobody
9
2025-02-26
2023-04-13
Maksym
No

I tried to import CSV file to my MS SQL, but I received error like this:

Incorrect syntax near the keyword 'WHEN'. [20018] (severity 15) [MERGE [dbo].[User] USING (VALUES('16', '2023-03-26 10:59:15', 'test@gmail.com', '129', 'Testststst', '', 'test', '5', '0', '0', '0', NULL, NULL, '[]', '[]', '2023-03-26 10:59:15', '2023-03-26 10:58:15', '0', '1', '0', NULL, '67', NULL, '10', '')) AS source (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25) ON WHEN MATCHED THEN UPDATE SET [Id] = '16', [RegistrationUtcDate] = '2023-03-26 10:59:15', [GoogleLogin] = 'test@gmail.com', [Role] = '129', [Description] = 'Testststst', [Phone] = '', [Nickname] = 'test', [BloggerRate] = '5', [BloggerRatesCount] = '0', [NotificationSettings] = '0', [IsDeleted] = '0', [DeletionReason] = NULL, [DeletionUtcDate] = NULL, [BloggerChannels] = '[]', [BloggerNetworks] = '[]', [LastSessionStartUtcDate] = '2023-03-26 10:59:15', [LastSessionEndUtcDate] = '2023-03-26 10:58:15', [IsVerifiedBlogger] = '0', [CanPublish] = '1', [IsBanned] = '0', [BannedUntilUtcDate] = NULL, [BloggerCategory] = '67', [ReferalId] = NULL, [BloggerPercent] = '10', [TwitchLogin] = '' WHEN NOT MATCHED THEN INSERT ([Id], [RegistrationUtcDate], [GoogleLogin], [Role], [Description], [Phone], [Nickname], [BloggerRate], [BloggerRatesCount], [NotificationSettings], [IsDeleted], [DeletionReason], [DeletionUtcDate], [BloggerChannels], [BloggerNetworks], [LastSessionStartUtcDate], [LastSessionEndUtcDate], [IsVerifiedBlogger], [CanPublish], [IsBanned], [BannedUntilUtcDate], [BloggerCategory], [ReferalId], [BloggerPercent], [TwitchLogin]) VALUES ('16', '2023-03-26 10:59:15', 'test@gmail.com', '129', 'Testststst', '', 'test', '5', '0', '0', '0', NULL, NULL, '[]', '[]', '2023-03-26 10:59:15', '2023-03-26 10:58:15', '0', '1', '0', NULL, '67', NULL, '10', '');] 16:01:49 SQL command

I received this SQL command when expand error:

BEGIN TRANSACTION;
DELIMITER ;;
MERGE [dbo].[User] USING (VALUES('16', '2023-03-26 10:59:15', 'test@gmail.com', '129', 'Testststst', '', 'test', '5', '0', '0', '0', NULL, NULL, '[]', '[]', '2023-03-26 10:59:15', '2023-03-26 10:58:15', '0', '1', '0', NULL, '67', NULL, '10', '')) AS source (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25) ON  WHEN MATCHED THEN UPDATE SET [Id] = '16', [RegistrationUtcDate] = '2023-03-26 10:59:15', [GoogleLogin] = 'test@gmail.com', [Role] = '129', [Description] = 'Testststst', [Phone] = '', [Nickname] = 'test', [BloggerRate] = '5', [BloggerRatesCount] = '0', [NotificationSettings] = '0', [IsDeleted] = '0', [DeletionReason] = NULL, [DeletionUtcDate] = NULL, [BloggerChannels] = '[]', [BloggerNetworks] = '[]', [LastSessionStartUtcDate] = '2023-03-26 10:59:15', [LastSessionEndUtcDate] = '2023-03-26 10:58:15', [IsVerifiedBlogger] = '0', [CanPublish] = '1', [IsBanned] = '0', [BannedUntilUtcDate] 
(0.002 s)
1 Attachments

Discussion

  • Jakub Vrána

    Jakub Vrána - 2025-02-19
    • status: open --> pending-accepted
     
  • Jakub Vrána

    Jakub Vrána - 2025-02-19

    This happens if there's no primary key.

     
  • Jakub Vrána

    Jakub Vrána - 2025-02-26
    • status: pending-accepted --> closed-fixed
     
  • Jakub Vrána

    Jakub Vrána - 2025-02-26

    Fixed by 70f9ff7.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.