Trying to run the following and not getting good results. What am I missing? It returns whether it finds the column, however it does not return whether it does not either.declare c1 cursor for select name from dbo.sysdatabases (nolock) where name not in ('master','model','msdb','northwind','pubs','tempdb','setups') order by name declare @v_run varchar(1000), @dbname varchar(250),@ct int SET QUOTED_IDENTIFIER ON open c1 fetch next from c1 into @dbname while (@@fetch_status <> -1) begin IF LEFT(@dbname,8)<>'DB_0000_' begin print '**** '+@dbname+' ****' print ' ' set @v_run = 'USE '+@dbname+';(SELECT COUNT(QUOTENAME(TABLE_NAME)) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = ''BASE TABLE'' AND QUOTENAME(TABLE_NAME) = ''[scheduledPayment]'')' --print @v_run exec (@v_run) select @v_run = @ct SELECT CASE @ct WHEN 1 THEN 'scheduledPayment is found' WHEN 0 THEN 'scheduledPayment is not found' end From @v_run --if @v_run <> '1' -- begin -- print 'scheduledPayment is found' -- end --else -- begin -- print 'scheduledPayment is not found' -- end --end fetch next from c1 into @dbname end close c1 deallocate c1
Thanks,Kent