Home Forums SQL Server 2008 T-SQL (SS2K8) Rolling Max Value RE: Rolling Max Value<!-- 864 -->

  • The Quirky Update is easy to get, assuming that you already know the rules to follow.

    Here's an example with your sample data.

    DECLARE @Value float=0,

    @id int

    UPDATE t SET

    @Value = MaxRollingValue = CASE WHEN Value > @Value THEN Value ELSE @Value END,

    @id = RID

    FROM #dat t WITH( TABLOCKX)

    OPTION( MAXDOP 1)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2