Dear Evil,
Let me see and understand you.
If we have a query follow:
selectw.Unidade,
w.Data,
w.Interface,
w.NomeInterface
from( select c.unidade,
c.Data,
c.Interface,
c.NomeInterface
from cad_interface c
inner join sam.dbo.Unidade u
on(c.unidade=u.codigounidade)
where left(interface,6)='Inform'
and unidade = 999
and data between 20120701 and 20120702 ) as w
left outer join
( select dataint Data,
left(nomeint,11) COLLATE Latin1_General_CI_AS 'Interface',
SUBSTRING(nomeint,4,2) Unidade
from openquery(BS,'select * from PDTABLE')
where SUBSTRING(nomeint,1,1) = 'P' ) as b
on(w.data= b.data
and w.unidade= b.Unidade
and w.nomeinterface= left(b.interface,8))
order by w.data, w.unidade
In SQL Server 2K or 2K5 the WHERE clause where SUBSTRING(nomeint,1,1) = 'P' is run first in the subquery and then it does the join. However, in SQL Server 2K8 the engine return all informations and then after it does the join?
Thanks for help
Antonio Estima