UPDLock

  • DECLARE @Dummy int

    SELECT @Dummy = COUNT(*) FROM [dbo].[FundingRate] WITH (UPDLOCK)

    /* Note: LoadOne should load DELETED row, for delete action*/

    /*LoadAll should load LIVE rows*/

    /*Metadata which specifies how this data should be aggregated*/

    SELECT 'FundingRate' AS EntityType, 'FundingRate' AS Component

    /*Domain object Data*/

    SELECT FundingRateId,

    CurrencyCode,

    InterestRateId,

    StartDate,

    EndDate,

    FundingRateStatus,

    CreatedDateTime,

    CreatedBy,

    ModifiedDateTime,

    ModifiedBy,

    DeletedDateTime,

    DeletedBy,

    Version

    FROM [dbo].[FundingRate]

    WHEREFundingRateStatus = 'LIVE'

    ORDER BY CurrencyCode,StartDate

    Actually this is my sp where UPDLOCk IS used.

    When it is required to apply locks in every fields of the table?

  • Why are you applying an update lock on the count? An update lock is usually used to indicate that the data selected will shortly be updated.

    What are you trying to do?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply