SELECT *
FROM [shared].[Document] D
LEFT JOIN [shared].[Document] THUMB ON D.[ObjectId]=THUMB.[ObjectId] AND D.[Object]=57 AND THUMB.[Object]=57 AND D.[Id]<>THUMB.[ID]
AND LEFT(D.[Name], LEN(D.[Name])-CHARINDEX('.', reverse(D.[Name])))=LEFT(THUMB.[Name], LEN(THUMB.[Name])-CHARINDEX('.', reverse(THUMB.[Name])))
“While you’re refreshing yourself,” said the Queen, “I’ll just take the
measurements.” And she took a ribbon out of her pocket, marked in
inches, and began measuring the ground, and sticking little pegs in
here and there.