LEFT OUTER JOIN [INVENTTRANS]
ON #TEMP.VOUCHERPHYSICAL=[INVENTTRANS].VOUCHERPHYSICAL
WHERE [INVENTTRANS].ITEMID = #Temp.INVENTDIMID
This provides me nearly the result I am looking for. About 1/4th of the desired results are eliminated because INVENTDIMID
has a suffix appended to it in certain cases.
What is the proper syntax to succeed in a like clause similar to this intent.
WHERE '[INVENTTRANS].ITEMID%' like #Temp.INVENTDIMID
Alternatively, if there is no short hand way to do this, what is the most effective long handed way about it.
Thanks
I am not sure if I completely understand the question but it appears you want to apply a predicate to a like statement that compares something else that is fixed and not in text you supply.
I always do something like this:
Where (ColumnName) like '%' + (OtherColumnName) + '%'
This is basically applying a wildcard around either side of the column you are trying to relate to. It will work for variables or columns.
UPDATE 5-21-13
Simple example of two table variables that self populate and work with wild card matcing on the second table variable. Code will run as is on SQL 2008 or higher in SQL Management Studio:
declare @Person Table ( personID int identity, person varchar(8));
insert into @Person values ('Brett'),('Sean'),('Chad'),('Michael'),('Ray'),('Erik'),('Queyn');
declare @Match table ( Description varchar(4));
insert into @Match values ('B'), ('S'),('e')
Select top 100
p.*
, m.Description as 'MatchedOn'
from @Person p, @Match m
where p.person like '%' + m.Description + '%'