Created
March 31, 2022 21:02
-
-
Save rruntsch/68a1a4807cc64ce04f01bc9900e3ebe8 to your computer and use it in GitHub Desktop.
Query data from SQL Server and write its results in the JSON format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- File: customer_location_json.sql | |
-- Date: March 31, 2022 | |
-- Author: Randy Runtsch | |
-- Description: Get the names and location (city, state or province, | |
-- postal code, and country or region name | |
-- for all customers in the AdventureWorks2019 database. | |
-- Return the data in JSON format. | |
USE AdventureWorks2019; | |
GO | |
SELECT | |
-- TOP (5) | |
BusinessEntityID | |
, City | |
, StateProvinceName | |
, PostalCode | |
, CountryRegionName | |
FROM [AdventureWorks2019].[Sales].[vIndividualCustomer] | |
ORDER BY | |
CountryRegionName | |
, StateProvinceName | |
, City | |
FOR JSON PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment