Skip to main content
deleted 22 characters in body
Source Link
marc_s
  • 747.8k
  • 180
  • 1.4k
  • 1.5k

I have a JSON string that I am trying to import into my MSSQLSQL Server database using the OPENJSON WITHOPENJSON WITH but I am having issues because I think the JSON "field names" contain a forward slash.

What else would I need to do in order to get the start and end values? At the moment I just get NULLS...

DECLARE @JSONText NVarChar(max) = '[{
    "Labour Resource Name": "ABC Consulting",
    "Start Date/Time": "2020-07-06T06:30:00",
    "End Date/Time": "2020-07-06T10:30:00"
}]'

SELECT *  
FROM OPENJSON (@JSONText)
                            WITH (
                                  [Labour Resource Name] NVarChar(512),
                                  [Start Date/Time] NVarChar(50),
                                  [End Date/Time] NVarChar(50)
                          ) 

I have a JSON string that I am trying to import into my MSSQL database using the OPENJSON WITH but I am having issues because I think the JSON "field names" contain a forward slash.

What else would I need to do in order to get the start and end values? At the moment I just get NULLS...

DECLARE @JSONText NVarChar(max) = '[{
    "Labour Resource Name": "ABC Consulting",
    "Start Date/Time": "2020-07-06T06:30:00",
    "End Date/Time": "2020-07-06T10:30:00"
}]'

SELECT * FROM OPENJSON (@JSONText)
                            WITH (
                                  [Labour Resource Name] NVarChar(512),
                                  [Start Date/Time] NVarChar(50),
                                  [End Date/Time] NVarChar(50)
                          ) 

I have a JSON string that I am trying to import into my SQL Server database using the OPENJSON WITH but I am having issues because I think the JSON "field names" contain a forward slash.

What else would I need to do in order to get the start and end values? At the moment I just get NULLS...

DECLARE @JSONText NVarChar(max) = '[{
    "Labour Resource Name": "ABC Consulting",
    "Start Date/Time": "2020-07-06T06:30:00",
    "End Date/Time": "2020-07-06T10:30:00"
}]'

SELECT *  
FROM OPENJSON (@JSONText)
     WITH ([Labour Resource Name] NVarChar(512),
           [Start Date/Time] NVarChar(50),
           [End Date/Time] NVarChar(50)
          ) 
Source Link

Dealing with special characters in SQL OPENJSON WITH command?

I have a JSON string that I am trying to import into my MSSQL database using the OPENJSON WITH but I am having issues because I think the JSON "field names" contain a forward slash.

What else would I need to do in order to get the start and end values? At the moment I just get NULLS...

DECLARE @JSONText NVarChar(max) = '[{
    "Labour Resource Name": "ABC Consulting",
    "Start Date/Time": "2020-07-06T06:30:00",
    "End Date/Time": "2020-07-06T10:30:00"
}]'

SELECT * FROM OPENJSON (@JSONText)
                            WITH (
                                  [Labour Resource Name] NVarChar(512),
                                  [Start Date/Time] NVarChar(50),
                                  [End Date/Time] NVarChar(50)
                          )