I have a database table that stores error messages, and I want to run various queries on them. First, I get an overall count by grouping them like this:
select MessageText, COUNT(*) from MessageLog group by MessageText
And the result is:
1 Input string was not in a correct format 4
2 Value cannot be null. Parameter name: Int 8
3 Value cannot be null. Parameter name: String 1
Now, if I try to select messages by the text string, some of them return no results even though the messages exist. For example,
select * from MessageLog where MessageText = 'Value cannot be null. Parameter name: Int'
does not return any results, even though the previous query shows there are 8 of them. What is it about this string that fails to match?
My guess is that you either have white spaces in your MessageText that you are not accounting for or you are doing something you are not showing us. I ran the following query:
and got the expected results.