April 29, 2013 at 12:46 pm
I have this query:
declare @controlnumber varchar(13)
set @controlnumber = '0210300000001'
select *
from Cards
where controlNum like ''''+SUBSTRING(@controlnumber,1,5)+'%'+''''
it returned nothing
however if I change the where clause to controlnum like '02103%' then it worked. Did I miss a quote or something?
thanks for all the help and advice.
April 29, 2013 at 1:10 pm
phamm (4/29/2013)
I have this query:declare @controlnumber varchar(13)
set @controlnumber = '0210300000001'
select *
from Cards
where controlNum like ''''+SUBSTRING(@controlnumber,1,5)+'%'+''''
it returned nothing
however if I change the where clause to controlnum like '02103%' then it worked. Did I miss a quote or something?
thanks for all the help and advice.
Try this:
declare @controlnumber varchar(13)
set @controlnumber = '0210300000001'
select *
from Cards
where controlNum like SUBSTRING(@controlnumber,1,5) + '%'
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply