[RESOLVED] Wondering why this doesnt work
The following code produces 0 results, however, if I replace '%' with '%%' I get the entire table returned. Any ideas?
declare @blah char(2)
set @blah = '%'
SELECT * FROM dwJobs WHERE cono LIKE @blah
[257 byte] By [
stin] at [2007-11-20 11:29:15]

# 1 Re: [RESOLVED] Wondering why this doesnt work
because CHAR is a fixed length string, it will padded with spaces.
So when you assign '%' to it it will be equal to '% ' (note the space)
So your query will be :
SELECT * FROM dwJobs WHERE cono LIKE '% '
which will return records with 'cono' Starts with anything and has the last character equal to space.
using VARCHAR instead of CHAR can solve this problem.
hspc at 2007-11-9 13:45:43 >
