Alan writes "I need to delete duplicate records from my SQL 7.0 database SP2. OS: Windows 2000 Server.I have been using some of the solutions provided by graz on 3/26/01.Here is what I have done:1. First I want to create a temporary table with a list of memberid's I want to keep. note: memberid is a primary key in table memberI used: select computerno, RecCount=count(*), MembertoKeep = min(memberid)into resignedtempfrom resignedmembersgroup by computernohaving count(*) > 1order by count(*) desc, computernoresult in table resignedtempcomputerno RecCount MembertoKeep --------------------------------------2390025 13 2062162390165 13 212573
2. Then I want to delete all records having duplicate computernos in "resignedmembers", except those with memberid's in table "resignedtemp", from table "member" delete from memberwhere memberid in (select memberid from resignedmembers where computerno in ( select computerno from resignedmembers group by computerno having count(*) > 1))and where memberid not in ( select memberid from resignedtemp)
I get this message:Server: Msg 156, Level 15, State 1, Line 10Incorrect syntax near the keyword 'where'.Can you please help me here.ThanksAlan"