top of page

SQL Server to JSON

Export as JSON wiht Customer as JSON root:

SELECT [CustomerKey]
      ,[GeographyKey]
      ,[CustomerAlternateKey]
      ,[Title]
      ,[FirstName]
      ,[MiddleName]
      ,[LastName]
      ,[NameStyle]
      ,[BirthDate]
  FROM [AdventureWorksDW2017].[dbo].[DimCustomer]
  FOR JSON PATH, ROOT('Customer') 

Result:

"Customer": [
        {
            "CustomerKey": 11000,
            "GeographyKey": 26,
            "CustomerAlternateKey": "AW00011000",
            "FirstName": "Jon",
            "MiddleName": "V",
            "LastName": "Yang",
            "NameStyle": false,
            "BirthDate": "1971-10-06"
        },...

JSON
bottom of page