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)
This happens if there's no primary key.
Fixed by 70f9ff7.