select TransactionItemId as documentid, booktype from tblTransactionItem where book = '1763' and page = '2152' and booktype = 'OR' and doctype not in ('ADP', 'CSUP', 'CERDC', 'DOMR', 'MIL', 'JUV', 'PRBC', 'PRO', 'FL', 'INM')select location as imagepath from tblPage tp inner join [Image.Live_repl_external].dbo.tblimage ti on tp.ReleasableImageId = ti.ImageId inner join tblTransactionItem tai on tp.TransactionItemId = tai.TransactionItemId where tp.TransactionItemId = '1009694' and ImageTypeEnum = 'Primary' and (ishiddenfromweb = 0 or ishiddenfromweb is null) order by pagesequencenumber