The below query was working fine for me to display the required data, now the requirement has changed, The RAISERROR( @msg,11,1) was used to pass the control to catch block for any existence of the any of the 4 table with col name RAW else run the main queryNow the requirement is change, even if one of the table is not having RAW as the column then the main query should be executed to display result for that table. could any one help me in modifying this blockIn short if a table has RAW as col ignore that table and pull data for other tables, earlier in the below query if any of the table has RAW as col then I was ignoring all other table and jumping to catchTable which has RAW column can be shown in the main query as 'table has Raw col' some thing like thisDECLARE @Col_name VARCHAR(100)DECLARE @tab_nam VARCHAR(100)DECLARE @msg VARCHAR(500)DECLARE @SQLString VARCHAR(3000) SELECT @Col_name= column_name ,@tab_nam=table_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'at_allow' and column_name ='RAW' IF @Col_name = 'RAW' BEGIN SET @msg= 'File ''at.allow'' does not exist.' RAISERROR( @msg,11,1) END SELECT @Col_name= column_name ,@tab_nam=table_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'at_deny' and column_name ='RAW' IF @Col_name = 'RAW' BEGIN SET @msg= 'File ''at.deny'' does not exist.' RAISERROR( @msg,11,1) END SELECT @Col_name= column_name ,@tab_nam=table_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'cron_allow' and column_name ='RAW' IF @Col_name = 'RAW' BEGIN SET @msg= 'File ''cron.allow'' does not exist.' RAISERROR( @msg,11,1) END SELECT @Col_name= column_name ,@tab_nam=table_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'cron_deny' and column_name ='RAW' IF @Col_name = 'RAW' BEGIN SET @msg= 'File ''cron.deny'' does not exist.' RAISERROR( @msg,11,1) ENDWITH CTE([UserName]) AS ( SELECT [UserName] AS [UserName] FROM at_allow UNION SELECT [UserName] AS [UserName] FROM at_deny UNION SELECT [UserName] AS [UserName] FROM cron_allow UNION SELECT [UserName] FROM cron_deny ) SELECT [UserName], [Cron Allow] = CASE WHEN EXISTS(SELECT 1 FROM cron_allow WHERE [UserName] = CTE.[UserName]) THEN 'Yes' ELSE 'No' END, [Cron Deny] = CASE WHEN EXISTS(SELECT 1 FROM cron_deny WHERE [UserName] = CTE.[UserName]) THEN 'Yes' ELSE 'No' END, [At Allow] = CASE WHEN EXISTS(SELECT 1 FROM at_allow WHERE [UserName] = CTE.[UserName]) THEN 'Yes' ELSE 'No' END, [At Deny] = CASE WHEN EXISTS(SELECT 1 FROM at_deny WHERE [UserName] = CTE.[UserName]) THEN 'Yes' ELSE 'No' END FROM CTE EXEC (@SQLString)END TRYBEGIN CATCH SELECT ERROR_MESSAGE() AS [UserName],'' AS [Cron Allow],'' AS [Cron Deny] ,'' AS [At Allow],'' AS [At Deny]END CATCH
-Neil