declare @curdb nvarchar(100)
declare @lastdb nvarchar(100)
declare @lastCount int
declare @filters nvarchar(500)
declare @MyCount int
declare @id nvarchar(100)


select @lastCount=count(id) from [2014].[dbo].[dindan] where time1>='201-01-01' and time1<='2014-12-31' and status3='OK' and [002].[dbo].[dindan].[id] != [001].[dbo].[dindan].[id]
while @lastCount > 0 begin
select top 1 percent @id=id from [db].[dbo].[dindan] where time1>='201-01-01' and time1<='2014-12-31' and status3='OK' and [002].[dbo].[dindan].[id] != [001].[dbo].[dindan].[id] 
end

--insert into [001].[dbo].[dindan] select * from [002].[dbo].[dindan] where time1>='201-01-01' and time1<='2014-12-31' and status3='OK' and [002].[dbo].[dindan].[id] != [001].[dbo].[dindan].[id]
