Re: update statement

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: hngo01 (hngo01_at_hotmail.com)
Date: 03/19/04


Date: Fri, 19 Mar 2004 07:51:15 -0800

Thank you but this would not work because if I have this
data. I like to get the one that immediately above the
TOOL which is 'DDD2323' NOT the one below the TOOL which
is 'QWQWQWQ' . Thanks a lot

PrimaryKey Name TestCode Result UnitNumber
1 aaaa %UN 12345NN
2 aaaa TOOL 1
3 bbbb %UN 11AAAAA
4 bbbb %UN DDD2323
5 bbbb TOOL 1
6 bbbb %UN QWQWQWQ

>-----Original Message-----
>Try:
>
>--replace #t with the tablename you have
>
>begin transaction
>update #t
>set unitnumber
>=(select result from #t a
> where a.name = #t.name and primarykey =
> (select max(primarykey) from #t where #t.name = a.name
and testcode = '%UN') )
>where testcode ='TOOL'
>
>--check the data and commit/rollback accordingly.
>
>--
>Vishal Parkar
>vgparkar@yahoo.co.in
>
>
>.
>



Relevant Pages

  • Re: update statement
    ... begin transaction ... where testcode ='TOOL' ... --check the data and commit/rollback accordingly. ...
    (microsoft.public.sqlserver.programming)
  • Re: update statement
    ... PrimaryKey Name TestCode Result UnitNumber ... >begin transaction ... >Vishal Parkar ...
    (microsoft.public.sqlserver.programming)