Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8457765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:53:40+00:00 2026-06-10T12:53:40+00:00

Our customer complains that the following SQL view causes blocking of their primary information

  • 0

Our customer complains that the following SQL view causes blocking of their primary information system. I need to find if it is true (as they do also other things in the time and they are not sure), and I would like to fix the situation.

Background: The following is the simplified legacy SQL code that is used to extract the data from the Navision (now Microsoft Dynamics-Nav or how they call it) installed on Microsoft SQL Server 2008.

The view is used from a SSIS package to extract the data to txt files with fixed column width. The resulting files are imported to another software that is otherwise not directly related to Navision. The package is launched as a job via the SQL Server Agent. It takes about 10 minutes to run.

How can I find whether the data extraction process blocks the other activities? Is the SELECT always blocking automatically? If yes, can the view be improved somehow to avoid blocking?

CREATE VIEW [A_Company$my_view] AS
SELECT ItemLedgerEntry.[Document No_] AS DocumentNo,
    ...
    CAST(CONVERT(DECIMAL(14,2),
                 ROUND((SELECT SUM([Sales Amount (Actual)])
                        FROM [A_Company$Value Entry] AS ValueEntry
                        WHERE ValueEntry.[Item Ledger Entry No_] = ItemLedgerEntry.[Entry No_]),
                       2)) AS VARCHAR(14)) AS SalesAmount,
    ...
    Dim1.[Dimension Value Code] AS Dim1,
    ...
    COALESCE((select top 1 [Group Code]
              from [A_Company$Statistic Group Accom]
              where [Type] = 1
                  and [Sales Code] = ItemLedgerEntry.[Source No_]
                  and [Ship-to Code] = ItemLedgerEntry.[Source No_ 3]
                  and [Starting Date] <= ItemLedgerEntry.[Posting Date]
              order by [Starting Date] desc),
             (select top 1 [Group Code]
              from [A_Company$Statistic Group Accom]
              where [Type] = 1
                  and [Sales Code] = ItemLedgerEntry.[Source No_]
                  and [Ship-to Code] = ''
                  and [Starting Date] <= ItemLedgerEntry.[Posting Date]
              order by [Starting Date] desc), ''
              ) as StatisticGroup

FROM [A_Company$Item Ledger Entry] AS ItemLedgerEntry
    LEFT OUTER JOIN [A_Company$Item] AS Item ON (Item.[No_] = ItemLedgerEntry.[Item No_])
    ...
    LEFT OUTER JOIN [A_Company$Salesperson_Purchaser] AS Salesperson_Purchaser
                 ON (Salesperson_Purchaser.[Code] = Customer.[Salesperson Code])

    LEFT OUTER JOIN [A_Company$Ledger Entry Dimension] AS Dim1
      ON (ItemLedgerEntry.[Entry No_] = Dim1.[Entry No_]) AND (Dim1.[Table ID] = 32) AND
         (Dim1.[Dimension Code] = (SELECT [Shortcut Dimension 1 Code] FROM [A_Company$General Ledger Setup]))
    ...
    LEFT OUTER JOIN [A_Company$Ledger Entry Dimension] AS Dim8
      ON (ItemLedgerEntry.[Entry No_] = Dim8.[Entry No_]) AND (Dim8.[Table ID] = 32) AND
         (Dim8.[Dimension Code] = (SELECT [Shortcut Dimension 8 Code] FROM [A_Company$General Ledger Setup]))

WHERE ((ItemLedgerEntry.[Invoiced Quantity] <> 0)
      AND (ItemLedgerEntry.[Entry Type] = 1))

This is the real code where I tried to preserve all features that I think could cause the problems (the repeated parts removed). Is there any StackExchange forum where I can post the full code for review?

To avoid blocking is the first steps. Can you think about any improvement concerning the performance? (I am not good in SQL programming.)

Thanks a lot for your time,
Petr

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:53:41+00:00Added an answer on June 10, 2026 at 12:53 pm

    To some extent, this depend what the other processes are doing. What kind of locks are they requesting.

    You could try adding WITH (Nolock) after each of the table definitions in the above query.

    ie

    FROM [A_Company$Item Ledger Entry] AS ItemLedgerEntry WITH (NOLOCK)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our customer has a requirement to extend the functionality of their existing large government
I have an intranet site that our customer needs to access both internally and
Status Quo For our customer we are developing some libraries and applications that run
I've written a service for our customer that automatically transmits files to given destinations
I have the following scenario: A user on one our customer's website clicks a
Our customer has asked that our application be able to communicate through HTTPS. The
Our customer is complaining that our export file is too long; they would like
Last days as a result of some customer complains and discussion with our marketing
We have an application which we need to allow users from our customer's systems
Our customer request the functionality of logging changes in db. We need next structure:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.