SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS2005: DataFlow Task from OLE DB Source to Excel File Destination


SSIS2005: DataFlow Task from OLE DB Source to Excel File Destination

Author
Message
aaron.reese
aaron.reese
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2403 Visits: 907
Hi guys,

Once again it looks like Excel is the poor relation in SSIS.

I am trying to create a DataFlow task which connects to my database and runs an SQL SELECT statement into an Excel results set.

The SQL statement is as follows

SELECT
OBR.cppolref,
OBR.ValidFrom,
S.FSASegment,
S.Warning,
F.Deceased,
F.VIP,
F.AltAddress,
F.Flats,
F.HEC,
F.SpecialNeeds,
coalesce(F.SpecialNeedsDescription,'') as 'SpecialNeedsDescription',
PF.additionalElementPrice,
coalesce(count(CDC.complaintref),0) + coalesce(count(CMS.complaintref),0) as 'TotComplaints',
coalesce(count(CDC2.complaintref),0) + coalesce(count(CMS2.complaintref),0) as 'TotOpenComplaints',
coalesce(count(CDC3.complaintref),0) + coalesce(count(CMS3.complaintref),0) as 'TotOpenFSAComplaints'
FROM
opsBatchRecord OBR
join
Segments S on S.cppolref = OBR.cppolref
AND S.validfrom = OBR.Validfrom
join
cpfact F on F.cppolref = OBR.cppolref
AND F.validFrom = OBR.ValidFrom
join
priceFact PF on PF.cppolref = OBR.cppolref
AND PF.ValidFrom = OBR.ValidFrom
left join
CDCComplaints CDC on CDC.cppolref = OBR.cppolref
AND CDC.ValidFrom = (SELECT Max(ValidFrom) from CDCComplaints Where Validto <= f.validto)
left join
CMSComplaints CMS on CMS.cppolref = OBR.cppolref
left join
CDCComplaints CDC2 on CDC2.cppolref = OBR.cppolref
AND CDC2.ValidFrom = (SELECT Max(ValidFrom) from CDCComplaints Where Validto <= f.validto)
AND CDC2.Status = 'Open'
left join
CMSComplaints CMS2 on CMS2.cppolref = OBR.cppolref
AND CMS2.status in ('open','FSA open')

left join
CDCComplaints CDC3 on CDC3.cppolref = OBR.cppolref
AND CDC3.ValidFrom = (SELECT Max(ValidFrom) from CDCComplaints Where Validto <= f.validto)
AND CDC3.Status = 'Open'
AND CDC3.FSAReportable = 1
left join
CMSComplaints CMS3 on CMS3.cppolref = OBR.cppolref
AND CMS3.status = 'FSA open'
WHERE
OBR.BatchID = 1001
Group by
OBR.cppolref,
OBR.ValidFrom,
S.FSASegment,
S.Warning,
F.Deceased,
F.VIP,
F.AltAddress,
F.Flats,
F.HEC,
F.SpecialNeeds,
F.SpecialNeedsDescription,
PF.additionalElementPrice



Firstly, SSIS seems to choke on the colaesce() statement; when I put the code into Build Query it puts the coalesce in square brackets [coalesce] and treats it as a field name which then breaks the syntax - WHY!!!!!! Hehe I have replaced the coalesce() with isnull() and it seems to be happier, but still gives me an error message "syntax error in FROM clause" when I try to parse the query. Both versions of the query work just fine in Mgmt studio
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39290 Visits: 14411
Sorry if I am missing it, but are you running this SELECT against a SQL Server OLE DB connection or trying to run it against an Excel OLE DB connection?

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
aaron.reese
aaron.reese
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2403 Visits: 907
@OPC

Sorry for the delay in answering. It was running against the OLEDB datasource (SQL server 2005).
I eventually fudged it by creating the SELECT statement as a view in the database and calling that instead, filtering in the WHERE clause for the search conditions.
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39290 Visits: 14411
It's possible something with the OLE DB driver could not infer (or the database did not return an acceptable inference) the data types output by the expressions making up the last three columns in your SELECT. You may have had some luck adding a CAST around each of those columns but I am happy you got it sorted.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search