query number sign (#) in sql
Posted on 2011-09-25
I have a new customer that I'm building an application for that has data with --># in it.
I need to query on the field and need to understand how to do it.
If I'm trying to lookup data --> Joe's #123
SELECT * FROM MyTable WHERE Company Like 'Joe''s%'
This does not work (Incorrect syntax near '#'):
SELECT * FROM MyTable WHERE Company Like 'Joe''s '#'%'
I understand the correct answer is not to use reserved characters, but it's there now and I might work with them in the future to remove it, but...
Using SQL Server 2008
Thanks in advance for your help.