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

  • Home
  • SEARCH
  • 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 7128267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:07:15+00:00 2026-05-28T11:07:15+00:00

I have a SQL Server View: SELECT SOPOrderReturn.DocumentNo, StockItem.Code, SLCustomerAccount.CustomerAccountNumber, SOPOrderReturn.CustomerID, SOPDocDelAddress.PostalName, SOPDocDelAddress.AddressLine1, SOPDocDelAddress.AddressLine2,

  • 0

I have a SQL Server View:

SELECT SOPOrderReturn.DocumentNo,
       StockItem.Code,
       SLCustomerAccount.CustomerAccountNumber,
       SOPOrderReturn.CustomerID, 
       SOPDocDelAddress.PostalName,
       SOPDocDelAddress.AddressLine1,
       SOPDocDelAddress.AddressLine2,
       SOPDocDelAddress.AddressLine3, 
       SOPDocDelAddress.AddressLine4,
       SOPDocDelAddress.PostCode,
       SOPOrderReturnLine.LineQuantity,
       SOPOrderReturn.PromisedDeliveryDate, 
       StockItem.SpareNumber2,
       StockItem.SpareNumber3,
       StockItem.Name,
       StockItem.SpareText2,
       StockItem.SpareText1, 
       StockItem.SpareNumber1
FROM   SOPOrderReturn
       INNER JOIN SOPOrderReturnLine
          ON SOPOrderReturn.SOPOrderReturnID = SOPOrderReturnLine.SOPOrderReturnID
       INNER JOIN SOPDocDelAddress
          ON SOPOrderReturn.SOPOrderReturnID = SOPDocDelAddress.SOPOrderReturnID
       INNER JOIN SLCustomerAccount
          ON SOPOrderReturn.CustomerID = SLCustomerAccount.SLCustomerAccountID
       INNER JOIN StockItem
          ON SOPOrderReturnLine.ItemCode = StockItem.Code
WHERE  (NOT (StockItem.Code LIKE '%DELIVERY%')) AND
       (NOT (StockItem.Name LIKE '%DELIVERY%')) AND 
       (SOPOrderReturn.PromisedDeliveryDate > CURRENT_TIMESTAMP - 3)

When called ‘as is’ from .net using this query:

SELECT [DocumentNo],[Code],
       [CustomerAccountNumber],
       [CustomerID],[PostalName],
       [AddressLine1],[AddressLine2],
       [AddressLine3],[AddressLine4],
       [PostCode],[LineQuantity],
       [PromisedDeliveryDate],
       [SpareNumber2],
       [SpareNumber3],
       [Name],
       [SpareText2],
       [SpareText1],
       [SpareNumber1]
FROM [viwSalesOrdersRecent];

…everything is hunky dory. It returns all the 861 rows I expect to see, which matches what SQL Server says should be in the View.

However, when I call the View (as above) with the following Where clause tacked on it:

WHERE [DocumentNo] = @prmSalesOrderNumber AND [Code] = @prmStockCode;

The query returns the entire dataset, ignoring the existing Where clause inside the View, and I don’t understand this behaviour. I’m out of practice with SQL Server, haven’t touched it for 3 years, and I’m now back in the thick of it and completely out of my depth.

Any help will be much appreciated.

  • 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-05-28T11:07:16+00:00Added an answer on May 28, 2026 at 11:07 am

    Ultimately I never solved this, so I ended up chucking it towards Microsoft for them to look at.

    They have tentatively confirmed that this is caused by a bug in SQL Server, which they will hopefully remedy with a future update.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine I have the following SELECT statement in a view (SQL Server 2008): SELECT
I have a view in SQL server, something like this: select 6.71/3.41 as NewNumber
I have an SQL Server Reporting Services (SSRS) report, that uses a view. That
I currently have this statement in my SQL View (SQL Server 2008 R2) which
I have a view in SQL Server 2008 that I want to use for
I have a view in a SQL Server 2008 db that simply exposes about
I have a view in SQL server that translates from one schema version to
My SQL Server view SELECT geo.HyperLinks.CatID, geo.Tags.Tag, geo.HyperLinks.HyperLinksID FROM geo.HyperLinks LEFT OUTER JOIN geo.Tags
I have a ListView which I filled in from SQL Server view called view_ListaKlientow
Does anyone have experience with using indexed view in MS SQL Server 2008? I

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.