set nocount on
declare @id int = 1, @count int, @catalog int
declare @t_catalog table (id int identity(1,1) primary key, catalog int not null)
insert into @t_catalog (catalog) select inc from WWWBRON_SF2_T2_S86.dbo.catalog c where saved_is_ok = 1
and not exists(select * from aaa_save_cat_mongo_t2_s86 a where c.inc=a.catalog)
select * from @t_catalog order by id desc
set @count = @@rowcount
while @id <= @count
begin
select @catalog = catalog from @t_catalog where id = @id
raiserror('catalog: %d', 0, 1, @catalog)
exec copy_catalog2mongo
@catalog = @catalog,
@database = 'WWWBRON_SF2_T2_S86',
@address = 'http://192.168.5.19:8888',
@office_sql = 'SQLSERVER',
@office_db = 'ANEX',
@self_sql = 'WWW_0',
@developer = 1
if @@error=0
insert aaa_save_cat_mongo_t2_s86 (catalog, mess) values (@catalog,null)
set @id = @id + 1
end