Re: Manipulate duplicate rows



On Fri, 15 Apr 2005 09:59:02 -0700, bamboo wrote:

> I have two of the exact same rows, but I want to change one field of one of
>the rows. How do I do this?
>
>i.e.
>table_a
>group name revenue
>A jim 20
>A jim 20
>
>I want to change one jim to ken.
>
>I tried
>update table_a
>set name = 'ken'
>from (select top 1 * from table_a) as t1
>where table_a.group = t1.group
>
>but this updates both records

Hi bamboo,

This really should not have happened - each table in a database should
always have a primary key. You have just found out why: there is no way
for SQL Server to distinguish one row from the other, so all operations
will affect both or none.

Here's a link to an article that discusses some techniques to clean up
the mess: http://www.aspfaq.com/show.asp?id=2431.

And here's a link to an article that explains what you can do to prevent
this from happening again: http://www.aspfaq.com/show.asp?id=2509.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
.



Relevant Pages

  • Re: "Antique" cue case
    ... be aware that it is NOT an antique. ... Jim. ... He said he bought the exact same - not different - case. ...
    (rec.sport.billiard)
  • Re: event errors in W2K3
    ... I am getting the exact same errors. ... Jim ... > Event source for all = SideBySide. ... > Description varies: ...
    (microsoft.public.windows.server.general)
  • Re: MacExpo; the Ethiopian connection
    ... Maybe I've not use the exact right term there then JJ .. ... the term 'sock puppet' tends to be used to indicate someone who posts under ... saying 'yes Jim, I agree completely!' ... The droplet of saliva which hangs from them. ...
    (uk.comp.sys.mac)
  • RE: cannot "save as" in word 2002 on xp pro after security update
    ... We are experiencing this exact same problem (in exact same environment) for ... "Jim" wrote: ... The folder may be located in an unavailable location, ...
    (microsoft.public.word.application.errors)
  • Re: Code for ADO.NET: The Complete Reference
    ... It involves SQL Server 2000 and ... connect to a Database in SQL will not run and get the error. ... Jim ... website BUT when I go to the Osborne website and enter this ...
    (microsoft.public.dotnet.framework.adonet)