Articles in this section

Error When Updating Order Status

While updating the Order status, the following error may occur.

 

with LocationPaths (TmStockLocationID, FullPath)
As
(
    Select loc.TmStockLocationID,CAST(loc.Name AS nvarchar(max)) AS FullPath
    From TmStockLocation loc (NOLOCK)
    where loc.ParentID is null
    and loc.RowDeleted = 0
    AND loc.TmUnitID = @0

    UNION ALL

    Select loc.TmStockLocationID, Roots.FullPath + '\' + CAST(loc.Name AS nvarchar(max)) AS FullPath
    From TmStockLocation loc (NOLOCK)
    INNER JOIN LocationPaths AS Roots
            on Roots.TmStockLocationID = loc.ParentID
    and loc.RowDeleted = 0
    AND loc.TmUnitID = @0
)
SELECT '' [ChangedFields], TmStockLocation.TmStockLocationID, TmStockLocation.TmUnitID, TmStockLocation.Name, TmStockLocation.Coord, TmStockLocation.SortBy, TmStockLocation.ParentID, TmStockLocation.MovableAsset, TmStockLocation.OriginalUnitID, TmStockLocation.TransitLocation, TmStockLocation.MovableAssetStatus, TmStockLocation.TmLocationOnUnitID, TmStockLocation.LocationType, TmStockLocation.ExternalID, LocationPaths.FullPath
FROM TmStockLocation (NOLOCK)
LEFT JOIN LocationPaths on LocationPaths.TmStockLocationID = TmStockLocation.TmStockLocationID
WHERE TmStockLocation.RowDeleted = 0
   AND TmStockLocation.TmUnitID = @0
ORDER BY LocationPaths.FullPath

 

The issue is caused when SQL constructs the "full location" path, which times out due to missing or non-indexed data.

Adding additional indexing to the database will avoid this error occurring.

The needed index can be found attached to this article and needs to be run via SSMS.

 

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.