Need to ask about strange behaviour of SQL Server 2005.
What I need is to find records that contain ‘]’ or ‘[‘ in my column
I have a data in column like this
'6b51c65b-5773-415a-aec9-8482c404faef_megas_xlr[1].jpg'
When I run this query
select * from Theme where BackgroundImageUrl like '%[%'
then no records comes up, but running this below query
select * from Theme where BackgroundImageUrl like '%]%'
boils following output
'6b51c65b-5773-415a-aec9-8482c404faef_megas_xlr[1].jpg'
What’s wrong in that query? What do I need to do in order to search records having closing or starting brackets []?
EDIT..
For more clarification, here is my test data.
A[1].jpg
B[1.jpg
C1].jpg
And below are results that I got after running following combination
A select BackgroundImageUrl from Theme where BackgroundImageUrl like '%[%'
No Results
B select BackgroundImageUrl from Theme where BackgroundImageUrl like '%]%'
A[1].jpg
C1].jpg
C select BackgroundImageUrl from Theme where BackgroundImageUrl like '%[ [ ]%'
A[1].jpg
B[1.jpg
D select BackgroundImageUrl from Theme where BackgroundImageUrl like '%[ ] ]%'
No Results
What I need is that,
Case 1 : I need all records that contains ‘[‘
Case2 : I need all records that contains ‘]’
Query C fulfills my case 1 but I m not able to get result for my case 2
Well i just discovered my answer.
and