• Suth - Wednesday, June 28, 2017 1:47 AM

    For cases when I have the Inner Join the Output will be no good ? as I'm unable to Join back

    Unless there is a different way about going about this ?


    DELETE TOP(@DeleteBatchOf) FROM dbo.dxi_CDRLog
    INNER JOIN dbo.u_campaignHdr WITH (NOLOCK) ON u_campaignHdr.diallerCampaignId = dxi_CDRLog.qid 
    OUTPUT DELETED,* INTO dxi_CDRLog_archive
    WHERE dbo.u_campaignHdr.parentId = @CampaignId

    I'm not sure what you mean.   I'm going to reformat your DELETE statement and add table aliases and correct a syntax issue and see if that helps clarify what you're actually seeking to accomplish:
    DELETE TOP (@DeleteBatchOf) L
    OUTPUT DELETED.* INTO dbo.dxi_CDRLogArchive
    FROM dbo.dxi_CDRLog AS L
        INNER JOIN dbo.u_campaignHdr AS H WITH(NOLOCK)
            ON L.qid = H.diallerCampaignId
    WHERE H.parentId = @CampaignId;

    Let me know if your objective is solely to delete records from the dxi_CDRLog table or is something else.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)