select count(c_recid), c_recid, c_usertable_id
from s_link
group by c_recid, c_usertable_id order by c_usertable_id;
open MyCur
fetch next from MyCur into @countNum,@recId , @usertableId
while @@FETCH_STATUS= 0
begin
select @err = @@error
if @err = 0
begin try
set @mSQL = 'update T_' + substring(@usertableId, 1,13) +
' set I_FILECOUNT=' + convert(varchar(10),@countNum) + ' where id= ' + '''' +
@recId + ''''
exec(@mSQL)
end try
begin catch
--不处理
end catch
fetch next from MyCur into @countNum,@recId , @usertableId
end
close MyCur
deallocate MyCur