SELECT * FROM dbo.DocLibrary INNER JOIN dbo.DocExtensions ON dbo.DocLibrary.Extension = dbo.DocExtensions.Allowed WHERE dbo.DocLibrary.DocumentId like '84dda488-bf3e-44ca-b451-a675fd2dc6ec' and ActivateDate <=GetDate() and ExpireDate >= getdate() and dbo.DocLibrary.SecureLevel <= 0 and docLibrary.active =1