[windows2000] Re: MS SQL QUESTION: PLEASE HELP!

  • From: "Chris Berry" <compjma@xxxxxxxxxxx>
  • To: windows2000@xxxxxxxxxxxxx
  • Date: Fri, 22 Nov 2002 10:27:44 -0800

>From: "Matthew Studer" <matthew_studer@xxxxxxxxxxx>
>I am trying to make these 2 statements (see below) into1 statement
>so it will find AND delete duplicate entries.  I don't want to do each
>manually. It takes me too long to enter each value in that my select
>statement finds before deleteing it. >*************************************
>MS SQL SERVER VER 8.00   --UPS
>-- Step 1;This script will detect if any duplicates are in the
>NCT_UPS_Import_Data_Totals Table
>Select PackageReference2, count(PackageReference2)as 'TRANS'
>into ##TEMP1
>from NCT_UPS_Import_Data_Totals
>group by PackageReference2
>Select * from NCT_UPS_Import_Data_Totals A join ##TEMP1 B on
>A.PackageReference2 = B.PackageReference2 where B.TRANS <>'1'     --
>Step
>2;Use this script to delete the desired duplicate by modifing the >fields
>PackageReference2 and CODFrt Delete from NCT_UPS_Import_Data_Totals
>where
>PackageReference2 = 'MY INVOCE # GOES HERE' and CODFrt = 'MY NUMERIC
>VALUE
>FOR MY COD CHARGES GOES HERE'

First of all I'd say you're asking on the wrong list, second, no offense but 
your code is foul looking, haven't you heard of formatting?  However, now 
that I'm done comlaining, check out 
http://www.4guysfromrolla.com/webtech/sqlguru/q051200-2.shtml for a detailed 
explanation of how to delete duplicate entries.

Chris Berry
compjma@xxxxxxxxxxx
Systems Administrator
JM Associates

"And here in our server room you can see our Beowolf Cluster of C64's that 
keeps our enterprise on the very cutting edge of technology."

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


==================================
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm

Other related posts: