views:

66

answers:

2

The query below is working:

update  top(1) ShipBillInfo 
set     shipfirstname='kkk' 
where   CustomerId='134';

but it is showing error if i try to order by some Id: for example:

update  top(1) ShipBillInfo 
set     shipfirstname='kkk' 
where   CustomerId='134' 
order by 
        OredrGUID desc;
+2  A: 

why dont you do :

update ShipBillInfo 
set shipfirstname='kkk' 
where OrderGUID = (select top (1) OrderGUID  
                   from ShipBillInfo 
                   where CustomerId = 134 
                   order by OredrGUID desc )
stunaz
hey it works thanks .
Tina
A: 
With cte as (
select  top(1) shipfirtsname  
From ShipBillInfo 
where   CustomerId='134' 
order by  OredrGUID desc)
Update cte set shipfirstname='abc';
Remus Rusanu