select max(batchNumber)
from
(
select max(batchNumber) as batchNumber
from Adjustments
where store_Id = 8637
union all
select max(batchnumber)
from batch b
inner join Document d
on d.Document_Id = b.General_Id
where b.BatchType <> 'Warehouse' and b.TranTable = 'Document'
) t
Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/