Reputation: 41
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?
Upvotes: 1
Views: 1675
Reputation: 3591
Simply write a select where you give your columnnames another ALIAS.
You can use it 2 ways.
- You can export to CSV though your database in Management Studio
- 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
Upvotes: 3