I have a database (change) which I am trying to create an sql report on the detail field value. The issue is that the detail value displays a "phrase" and I need to evaluate based on this phrase, or a part of it.
SQL
SELECT *
FROM change
WHERE change.detail LIKE '%To: [Step Two]%'
I want it to display all of the values where detail contains "To: [1. Step Two]" but the result is consistently not returning anything, where there are table values for this. Following is an example of the full value of the detail field: "[Step] Changed From: [1. Step One] To: [1. Step Two]" The items in [] represent other values in the database as well
Presuming you're using SQL Server/TSQL, the problem you have is that the square bracket characters have a special meaning:
In order to literally match the square bracket characters, you need to escape them: