我前两天刚好写了一个存储过程,可以删除重复的记录(不好意思,献丑了)
不过只能删除一个字段的重复记录,如果要几个字段,你改一下就行了。
在SQL SERVER 7。0下调试通过。
CREATE PROCEDURE deldup @colnam char(12)
AS
Declare @value varchar
Declare @oldValue varchar
Declare Row Cursor For Select @colnam from sales for Update
Open row
Fetch next from row into @value
select @OldValue = ''
while (@@Fetch_status=0)
begin
if @value=@oldValue
delete sales where current of row
select @oldvalue=@value
fetch next from row into @value
end
close row
deallocate row