Link to home
Start Free TrialLog in
Avatar of sqlcurious
sqlcuriousFlag for United States of America

asked on

query taking a lot of time

WITH ISO_DR(PolicyID,  CompanyID, Persistency) AS
            (SELECT P.policyID, P.companyID, (SELECT effectiveDate from dbo.Policy where policyID =(select dbo.fnOriginalPolicyID(@policynum))) as PERSISTENCY
                  FROM Hallmark..Policy P WITH (NOLOCK))

Is there a better way to write this?
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

please post the actual query you are using ... you've only posted the cte
also post the definition of dbo.fnOriginalPolicyID
is this a cross database query?

or are the policy tables actually the same one?
ASKER CERTIFIED SOLUTION
Avatar of jogos
jogos
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, forgot the ;  before the WITH
Anny feedback?
Avatar of sqlcurious

ASKER

thnks