I’m not sure if this has already been asked – I looked around for quite a bit but couldn’t find anything.
My end result is to get data from several of my SQL database tables into a comma delimited flat file. Normally this would not be a problem but due to their many to one relationship and the format I’m forced to put it in it’s proving to be.
1st I’ve got one table, the Report table which has all basic info for a report. For example
CREATE TABLE tblReportExample
(
ReportID int,
ReportMonth smalldatetime,
ReportDetails varchar(500)
)
2nd I’ve got another table with cases for each report.
CREATE TABLE tblReportCasesExample
(
ReportID int,
ReportCase varchar(50)
)
3rd I have a flat file definition with the following:
ReportID, ReportMonth, ReportDetails, ReportCase1, ReportCase2, ReportCase3
What I need to do is add take the top three cases from the tblReportCasesExample for a report, join it somehow with the data in tblReportExample and add it to the flat file as ReportCase1, 2 and 3.
I’ve been looking at this thing all day and just can’t figure it out.
Any ideas?