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

  • 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

  • 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

  • @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.

  • 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

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply