--select COUNT(CONVERT(bigint,orderid)) from tbl
--where ISNULL(orderid,'''')<>''''
set nocount on ;
declare @s varchar(8000)
declare cu cursor for
select 'select COUNT(CONVERT(bigint,'+quotename(col)+')) from '+quotename(db)+'.'+quotename(sch)+'.'+quotename(tbl)+'
where ISNULL('+quotename(col)+','''')<>'''''
FROM [master].[dbo].[UnionALL]
where [istochang]=1 and mark not like '%线上库不存在'
open cu
fetch next from cu into @s
while @@FETCH_STATUS=0
begin
begin try
exec(@s)
--set @s=quotename(db)+'.'+quotename(sch)+'.'+quotename(tbl)+'OK!'
--print 'OK !'+@s
end try
begin catch
raiserror('Error',16,1,0)
--set @s= quotename(db)+'.'+quotename(sch)+'.'+quotename(tbl)+'ERRor!'
print 'Error !'+@s
print error_message()
end catch
fetch next from cu into @s
end
close cu
deallocate cu