INSERT INTO Getting error on second record values

  • I am trying to create a table to use for testing. I have codded the script correctly based on many posts I have seen. It is giving me a error "Msg 102, Level 15, State 1, Line 21 Incorrect syntax near ','." I dont know what I did wrong.

     

    /****** Object:  Table [dbo].[Temp_UnMatching_Mail2]    Script Date: 01/19/2022 12:26:05 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Temp_UnMatching_Mail2]
    (
    [Job_Num] [varchar](8) NULL,
    [Mail_Cat] [char](1) NULL,
    [Mail_Date] [date] NULL,
    [Mail_Class] [char](1) NULL,
    [TR_Scan_Date] [datetime] NOT NULL
    ) ON [PRIMARY]

    GO
    INSERT [dbo].[Temp_UnMatching_Mail2]
    ([Job_Num], [Mail_Cat], [Mail_Date], [Mail_Class], [TR_Scan_Date])
    VALUES
    (NULL, NULL, NULL, NULL, CAST(N'2021-12-27T09:41:19.000' AS DateTime),
    (NULL, NULL, NULL, NULL, CAST(N'2022-01-10T21:17:43.000' AS DateTime),
    ( N'1Q22 ', N'T', CAST(N'2021-11-12' AS Date), N'3', CAST(N'2021-12-18T15:24:56.000' AS DateTime),
    ( N'1Q22 ', N'T', CAST(N'2021-11-12' AS Date), N'3', CAST(N'2021-12-19T14:23:35.000' AS DateTime),
    ( N'1Q22 ', N'T', CAST(N'2021-11-12' AS Date), N'3', CAST(N'2021-12-28T13:05:44.000' AS DateTime),
    ( N'P102 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-21T00:16:48.000' AS DateTime),
    ( N'P102 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-21T05:57:11.000' AS DateTime),
    ( N'1A22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-18T08:10:03.000' AS DateTime),
    ( N'1A22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-23T15:21:15.000' AS DateTime),
    ( N'1A22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-23T22:09:33.000' AS DateTime),
    ( N'1A22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-24T06:57:16.000' AS DateTime),
    ( N'1A22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-24T07:12:44.000' AS DateTime),
    ( N'1A22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2021-12-29T03:00:31.000' AS DateTime),
    ( N'O683 ', N'P', CAST(N'2021-11-12' AS Date), N'3', CAST(N'2022-01-14T18:17:29.000' AS DateTime),
    ( N'O683 ', N'P', CAST(N'2021-11-12' AS Date), N'3', CAST(N'2022-01-15T12:36:38.000' AS DateTime),
    ( N'1B22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2022-01-06T16:54:18.000' AS DateTime),
    ( N'1B22 ', N'T', CAST(N'2021-12-27' AS Date), N'3', CAST(N'2022-01-07T11:49:07.000' AS DateTime),
    ( N'0107 ', N'C', CAST(N'2022-01-07' AS Date), N'3', CAST(N'2021-12-23T18:30:38.000' AS DateTime),
    ( N'0107 ', N'C', CAST(N'2022-01-07' AS Date), N'3', CAST(N'2022-01-08T21:07:04.000' AS DateTime),
    ( N'0107 ', N'C', CAST(N'2022-01-07' AS Date), N'3', CAST(N'2022-01-09T00:24:45.000' AS DateTime),
    ( N'0107 ', N'C', CAST(N'2022-01-07' AS Date), N'3', CAST(N'2022-01-09T01:53:20.000' AS DateTime),
    ( N'0107 ', N'C', CAST(N'2022-01-07' AS Date), N'3', CAST(N'2022-01-09T23:10:47.000' AS DateTime),
    ( N'0107 ', N'C', CAST(N'2022-01-07' AS Date), N'3', CAST(N'2022-01-10T03:37:06.000' AS DateTime),
    ( N'0107 ', N'C', CAST(N'2022-01-07' AS Date), N'3', CAST(N'2022-01-10T09:24:25.000' AS DateTime),
    ( N'P896 ', N'P', CAST(N'2022-01-28' AS Date), N'3', CAST(N'2021-12-31T08:29:40.000' AS DateTime),
    ( N'P896 ', N'P', CAST(N'2022-01-28' AS Date), N'3', CAST(N'2022-01-02T10:04:27.000' AS DateTime),
    ( N'P896 ', N'P', CAST(N'2022-01-28' AS Date), N'3', CAST(N'2022-01-03T13:53:18.000' AS DateTime),
    ( N'P896 ', N'P', CAST(N'2022-01-28' AS Date), N'3', CAST(N'2022-01-05T00:00:37.000' AS DateTime),
    ( N'P896 ', N'P', CAST(N'2022-01-28' AS Date), N'3', CAST(N'2022-01-05T00:58:14.000' AS DateTime),
    ( N'P896 ', N'P', CAST(N'2022-01-28' AS Date), N'3', CAST(N'2022-01-07T05:54:35.000' AS DateTime),
    ( N'P896 ', N'P', CAST(N'2022-01-28' AS Date), N'3', CAST(N'2022-01-07T13:48:40.000' AS DateTime);
    GO
  • It looks like your missing a closing bracket on each line.

     

    VALUES

    (NULL, NULL, NULL, NULL, CAST(N'2021-12-27T09:41:19.000' AS DateTime),

    So your closing the cast to date time, but not the row )

     

    VALUES

    (NULL, NULL, NULL, NULL, CAST(N'2021-12-27T09:41:19.000' AS DateTime)),

  • Thank you for your help I made the changes and it works now.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply