• Why not just add this to the join predicates to the Duplicates cte in the script I posted yesterday.

    AND d.ReferenceNumber <> r.ReferenceNumber

    I did try that Sean, but the output is currently doing two things. It IS showing me where the fields are identical apart from the reference number but confusingly it is still bringing through records where all the fields are matching, including the reference number.

    I am slightly confused about this as I thought using <> would stop records coming through where the reference number was the same.

    Yours (or anyone else's) thoughts about this would be appreciated.

    Re your second point, which I accept completely:

    I am more than a little concerned that you don't understand the code very well because that should be a pretty minor tweak.

    Up till now I have written fairly basic scripts then used filters, IIF statements etc in SSRS to get the data I want. The above is an attempt to get the data in a relatively presentable state prior to using SSRS. However, as I soon realised, I was probably trying to run before I could walk.

    Thanks.