Last active
March 31, 2022 21:04
-
-
Save rruntsch/36495ae585247fb88434ec92065f7f5b to your computer and use it in GitHub Desktop.
Select customer data from the SQL Server Adventure Works database to demonstrate saving returned data to a CSV file.
This file contains hidden or 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_csv.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 plain text format. | |
USE AdventureWorks2019; | |
GO | |
SELECT | |
-- TOP (5) | |
BusinessEntityID | |
, City | |
, StateProvinceName | |
, PostalCode | |
, CountryRegionName | |
FROM [AdventureWorks2019].[Sales].[vIndividualCustomer] | |
ORDER BY | |
CountryRegionName | |
, StateProvinceName | |
, City; | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment