DECLARE @memberMobile nvarchar(255)
DECLARE @I INT
DECLARE @memberid INT
DECLARE TEST CURSOR FOR
select MemberMobile from tbl_member group by MemberMobile having count(MemberMobile)>1
SET @I = 1
OPEN TEST
FETCH NEXT FROM TEST INTO @memberMobile
WHILE @@FETCH_STATUS = 0
BEGIN
declare test2 cursor for
select memberid from tbl_member where membermobile=@memberMobile
open test2
fetch next from test2 into @memberid
while @@fetch_status=0
begin
fetch next from test2 into @memberid
if @I>1
delete from tbl_member where memberid=@memberid
set @I = @I + 1
end
close test2
deallocate test2
set @I = 1
FETCH NEXT FROM TEST INTO @memberMobile
END
CLOSE TEST
DEALLOCATE TEST
DECLARE @I INT
DECLARE @memberid INT
DECLARE TEST CURSOR FOR
select MemberMobile from tbl_member group by MemberMobile having count(MemberMobile)>1
SET @I = 1
OPEN TEST
FETCH NEXT FROM TEST INTO @memberMobile
WHILE @@FETCH_STATUS = 0
BEGIN
declare test2 cursor for
select memberid from tbl_member where membermobile=@memberMobile
open test2
fetch next from test2 into @memberid
while @@fetch_status=0
begin
fetch next from test2 into @memberid
if @I>1
delete from tbl_member where memberid=@memberid
set @I = @I + 1
end
close test2
deallocate test2
set @I = 1
FETCH NEXT FROM TEST INTO @memberMobile
END
CLOSE TEST
DEALLOCATE TEST