You are here: Re: Identifying Duplicates in a table « MsSQL Server « IT news, forums, messages
Re: Identifying Duplicates in a table

Posted by Miks on 03/12/06 18:46

I have tried, My soultion may not be 100% perfect, Corrections welcome.

CREATE TABLE [dbo].[test2] (
[Name] [char] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Age] [int] NOT NULL ,
[flag] [int] NULL ,
[flag1] [int] NULL
) ON [PRIMARY]
GO

Table Values

Alen 19 0 0
Alen 19 0 0
Aex 20 0 0

Code
-----

declare @name varchar(20), @age int, @counts int

declare cust cursor for
select count(1), Name, Age from test2 group by Name, Age having
count(Name) > 1

open cust fetch next from cust
into @counts, @name, @age

while @@fetch_status = 0

if(@counts) = 2
update test2 set flag = 1 where Name = @name and Age = @age

fetch next from cust into @counts, @name, @age

close cust
deallocate cust

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация