troubleshooting Question

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

Avatar of PeterMatthews
PeterMatthews asked on
Microsoft SQL Server
1 Comment1 Solution783 ViewsLast Modified:
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)

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros