How to join two CSV files for SSRS Reporting - Part 2
SSRS report with Inner joining two CSV files
My recent article has covered “How to Use CSV file as DataSource for SSRS reports”, however one of the reader posted a question on that article, how to join two CSV files, i found it interesting hence i came up with this new article.
Joining two CSV files are as similar as joining two SQL
tables, but there is a small syntax difference, consider this article as second part of
previous article “How to Use CSV file as DataSource for SSRS reports” for better understanding on CSV as data source.
- First we will see the source data, i have created 2 CSV files with sample data of Mutual Funds and Asset Value, with common ID for Joining 2 data source.
- Fund_groups.csv
ID,Fund_Family,Fund_Family_Sub_Group,Line_Item,SubScript1,SBI Blue Chip,SBI Blue Chip G,Received from General Partner,12,SBI Blue Chip,SBI Blue Chip N,Withholdings taxes,23,SBI Blue Chip,SBI Blue Chip O,Received from Distributed General Partner,34,DSP BR Micro Cap,DSP BR Micro Cap G,Received from General Partner,15,DSP BR Micro Cap,DSP BR Micro Cap N,Withholdings taxes,26,Birla Sun Life,Birla Sun Life G,Received from General Partner,17,Birla Sun Life,Birla Sun Life N,Withholdings taxes,2
- Fund_Assets.csv
ID,Total_Fund_Asset1,100000002,15000003,80000004,400000005,410000006,40000007,4500000
- Next querying those 2 data sources, and using it in SSRS reports, for this we need to use OLEDB Driver to establish connection. (Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\CSV Source";Extended Properties="text;HDR=YES;FMT=Delimited")
- Write an ANSI SQL to join 2 CSV files, use complete file name as Table, we can
use any joins Inner, Left, Right or Full Outer join, below is a sample query.
SELECT
fg.ID, fg.Fund_Family, fg.Fund_Family_Sub_Group, fg.Line_Item, fg.SubScript,
fa.Total_Fund_Asset
FROM
Fund_groups.csv fg
INNER
JOIN Fund_Assets.csv fa ON fg.ID = fa.ID
This is how we can join 2 different csv files using ANSI SQL. please leave your comments, messages, feedback, thank you
No comments:
Post a Comment