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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 LIKE Statement not working when a colon is include

Author  Topic 

Husband
Starting Member

6 Posts

Posted - 2010-04-08 : 16:34:47
nevermind... problem solved.

Husband
Starting Member

6 Posts

Posted - 2010-04-08 : 18:17:30
UPDATE: it's not the colon, but the space after the colon that messes with things. For example:

SELECT __________ from ___________ where value LIKE '%Logon Type:%'

Works... it finds all entries. Whereas:

SELECT __________ from ___________ where value LIKE '%Logon Type: %'

Does not. The space after the colon messes up the query.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2010-04-08 : 18:18:26
the first select works perfectly fine for me.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2010-04-08 : 18:20:40
update based on your update. You need to TRIM the spaces from your app before you pass it to SQL. Everything between the %'s is matched exactly including the spaces. Obviously, there are no records with a space after "... Logon Type: "

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

Husband
Starting Member

6 Posts

Posted - 2010-04-08 : 18:38:55
Thank you dinakar, the issue was slightly stupid. What appeared to be a space was actually a TAB. It's odd, even when I copy/pasted it out of the database it appeared to be a space.

Sorry for wasting your time!
Go to Top of Page
   

- Advertisement -