1

TABLE-A

Client_Code   Client_Name   POST_HC_STK
123              Sam           100
456              Lily          500
568              Maria         200
789              Champ         300

Want Table output as under in CSV File

Client Code  Client Name    Post Haircut Stock
123              Sam           100
456              Lily          500
568              Maria         200
789              Champ         300

How to export Table-A with a change in column header into a CSV?

3
  • 1
    Hint: as is used to assign column names. Commented Nov 23, 2017 at 13:17
  • You mean to only change column name in CSV ? Commented Nov 23, 2017 at 13:18
  • Is there any Code/Scrip/Query which can use to Export output in to Csv File? Commented Nov 23, 2017 at 13:25

1 Answer 1

3

Simply write a select where you give your columnnames another ALIAS.

You can use it 2 ways.

  1. You can export to CSV though your database in Management Studio
  2. You can add it as OLE DB Source in SSIS and then add a flat file destination which points to a CSV File.

SQL Query

SELECT 
Client_Code as [Client Code]
,Client_Name as [Client Name]
,POST_HC_STK as [Post Haircut Stock]
FROM TableA

You can also write it like this - Which in my opinon is easier to read:

SELECT 
[Client Code]        = Client_Code,
[Client Name]        = Client_Name,
[Post Haircut Stock] = POST_HC_STK
FROM TableA
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.