Link to home
Start Free TrialLog in
Avatar of PeterMatthews
PeterMatthews

asked on

TSQL Update on same table selecting TopX recs from subquery but ALL records updating.

Why does the following TSQL resulits in all records being updated not Top 70.  Thanks

      Update Tbl_Stock_Take_Item
      Set Page_Num = @Page_Count
      where exists
      (Select Top 70 Tbl_Stock_Take_Item_Id
      From Tbl_Stock_Take_Item as Tabtwo
      Where Tbl_Stock_Take_Item.Tbl_Stock_Take_Item_Id = Tabtwo.Tbl_Stock_Take_Item_Id
      Order By Tabtwo.Location asc)

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg 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