>- see footer for list info -<
how about this:

<CFQUERY DATASOURCE="#Application.DocAdminDSN#" NAME="OuterLoop">
                SELECT Document_ID, ID
                FROM tbldetails
ORDER BY Document_ID
        </CFQUERY>

<cfoutput query="outerloop" group="Document_ID">
        <CFQUERY DATASOURCE="#Application.DocAdminDSN#" NAME="InnerLoop">
                DELETE  FROM tbldetails
                WHERE   (document_id=#Outerloop.Document_id#) AND (ID <> 
#OuterLoop.ID#)
        </CFQUERY>
</cfoutput>

you didn't need the cfloop 1054 times, the delete query will work fine without 
it.  and if the whole thing is slow, remove the cfsets as they're not really 
necessary.  Then grouping the output on the documentid, so you should only have 
to run the delete query once per document id, instead of once per row that 
contains that document id.


Duncan Cumming
New Media Developer
Customer Relations Management / Education
Fife Council
700 4105 / 01592 414105

>>> [EMAIL PROTECTED] 02/02/2006 15:21 >>>
>- see footer for list info -<
I have a file that has duplicate records in it ... Aghhhhh (In fact 
everything is duplicated at least once) Its an MS-SQL file. So to get rid of 
the dupes I wrote this .....

<CFQUERY DATASOURCE="#Application.DocAdminDSN#" NAME="OuterLoop">
                SELECT Document_ID, ID
                FROM tbldetails
        </CFQUERY>


<cfoutput query="outerloop">
        <cfset tmp1=#Outerloop.Document_id#>
        <cfset tmp2=#OuterLoop.ID#>
        <cfloop index="x" from="1" to="1054">
        <CFQUERY DATASOURCE="#Application.DocAdminDSN#" NAME="InnerLoop">
                DELETE  FROM tbldetails
                WHERE   (document_id=#tmp1#) AND (ID <> #tmp2#)
        </CFQUERY>

</cfloop>
</cfoutput>


This is really not very good and as you can imagine once started I might as 
well come back tomorrow to see if its finished .... Does anyone have a 
better CF way of doing this ...? I can't get at the actual tables so it has 
to be a CF solution....

Regards - Paul


_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo 

--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<


**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed and 
should not be disclosed to any other party. 
If you have received this email in error please notify your system manager and 
the sender of this message.

This email message has been swept for the presence of computer viruses but no 
guarantee is given that this e-mail message and any attachments are free from 
viruses.

Fife Council
Tel: +44 (0) 1592 414141
**********************************************************************
_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to