Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 Check string for number of errors

Author  Topic 

noobapap
Starting Member

2 Posts

Posted - 2012-02-03 : 17:01:53
Hi Folks

I hope you can help me out here. I'm working with a database where a particular table has a char(80) column called 'Details' which is used to report whether a process produced an error.

The output can look some like this.

Processing of task A complete.
Processing of task B complete.
Checks complete. Processed: 150. Errors 0.
Processing of task C complete.
Processing of task D complete.
Checks complete. Processed: 52. Errors 13.


Is it possible to do something if the column 'Details' contains Errors > 0 like set an variable to true or something?

I'm not too sure on where to start with conditional checks with a string and a wildcard so your help would be truly appreciated.

Thanks

noobapap
Starting Member

2 Posts

Posted - 2012-02-03 : 17:25:15
Figured it out.

I put the output of a select query into a variable and then done this...

IF @result NOT LIKE '%Errors 0%'
PRINT @result
ELSE
PRINT 'Errors Found'
Go to Top of Page
   

- Advertisement -