|
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]
|