declare qc_cursor cursor SCROLL OPTIMISTIC For
select siteName from tb_vhostcheck
open qc_cursor
declare @siteName nvarchar(50)
while @@fetch_status=0
begin 
fetch next from qc_cursor into @siteName
--print @siteName
        if not exists(select 1 from vhhostlist where s_comment= @siteName)
            begin
                print @siteName
                delete from tb_vhostcheck where siteName=@siteName
            end
        
end
close qc_cursor
deallocate qc_cursor
原文:http://www.cnblogs.com/mazey/p/6131450.html