SQL Query Assistance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Braithwaite
    New Member
    • Oct 2007
    • 22

    SQL Query Assistance

    Hi

    We are using Microsoft CRM and we have exported a list of service activities to a dynamic Excel worksheet. I have attempted to insert the name of customers that are related to service activities in the worksheet. When editing the SQL query I used the following script;

    SELECT activitypartycu stomer.partyidn ame,
    serviceappointm ent.subject ,
    serviceappointm ent.scheduledst art ,
    serviceappointm ent.scheduleden d ,
    serviceappointm ent.regardingob jectidname ,
    serviceappointm ent.activityid ,
    serviceappointm ent.scheduleddu rationminutes ,
    serviceappointm ent.serviceidna me
    FROM FilteredService Appointment as serviceappointm ent
    INNER JOIN FilteredActivit yParty as activitypartycu stomer
    ON serviceappointm ent.activityid = activityparty.a ctivityid
    WHERE (serviceappoint ment.schedulede ndutc >= dbo.fn_BeginOfL astMonth(GetUTC Date()) and serviceappointm ent.scheduleden dutc < dbo.fn_EndOfLas tMonth(GetUTCDa te()) and serviceappointm ent.ownerid = N'{4DEA2FCF-D238-DB11-A907-00137259CAFC}')

    It seemed to be successful however the partyid column contained the name of the owner of the service activity and below that row the name of the customer.

    I am sure it is the ON statement that is giving problems. I would really appreciate any assistance.

    Thanks
    M
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    I don't think there is any error with the query . It does what it is being asked to do in the syntax. If your requirment is different you might need to change the join part . It is really difficult to predict without the table structure.

    Comment

    Working...