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 6329011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:34:03+00:00 2026-05-24T17:34:03+00:00

[Disclaimer]: Currently we are running older SQL Server 2000, but we could update to

  • 0

[Disclaimer]: Currently we are running older SQL Server 2000, but we could update to SQL Server 2008 within the next 6 months or so.

Within our Manufacturing Environment, I have a very long piece of C# code to determine the following:

  1. Which Employee “owns” the product (defined as first Employee that works on it),

  2. What that product’s eventual Test_Result is at a Pressure Test station, and

  3. What that Product’s first Test_Result is at a Vacuum Test station.

All Test_Result values (stored in string values) are contained in a flat file table that evolved from an older Microsoft Excel spreadsheet. The database structure can not be easily modified because company machines and vendor machines alike write data to them.

Once a month or so, Management runs a report to display how many products each Employee owns, if the first Pressure Test was a success, and if an eventual Vacuum Test was a success.

My technique for doing this, currently, is all in SQL calls from C# code:

  • SELECT DISTINCT Serial_Number WHERE Date_Time BETWEEN @Date1 AND @Date2

During a month’s time, we could log anywhere from 1500 to 3500 different product Serial_Number values.

For each Serial_Number, I create an instance of a custom Product class that contains a PressureEmployee and a VacuumEmployee, both initialized to NULL.

  • Now, for each of these Product instances, I select all the data and order by the Date_Time field to determine which Employee performed the test actions first on a product.

The SQL for this is similar to the following quasi-code:

string sqlText = "SELECT Date_Time, Employee, System_ID, Test_Result " +
  "FROM Production " +
  "WHERE Serial_Number=@SN ORDER BY Date_Time";
using (SqlCommand cmd = new SqlCommand(sqlText, new SqlConnection(connStr))) {
  cmd.Parameters.Add("@SN", SqlDbType.NVarChar, 20);
  cmd.Connection.Open();
  foreach (var item in productList) {
    cmd.Parameters["@SN"].Value = item;
    SqlDataReader r = cmd.ExecuteReader();
    while (r.Read()) {
      string systemId = r["System_ID"].ToString();
      string testResult = r["Test_Result"].ToString();
      if (-1 < systemId.IndexOf("pressure")) {
        if (String.IsNullOrEmpty(item.PressureEmployee)) {
          item.PressureEmployee = r["Employee"].ToString();
        }
        // check that product ever passes
        if (-1 < testResult.IndexOf("pass")) {
          item.VacuumPass = true;
        }
      }
      if ((-1 < systemId.IndexOf("vacuum")) &&
          String.IsNullOrEmpty(item.VacuumEmployee)) {
        item.VacuumEmployee = r["Employee"].ToString();
        // product passes 1st time
        item.VacuumPass = (-1 < testResult.IndexOf("pass"));
      }
    }
  }
}

There is actually a lot more to this, but it should get the general idea across.

What I’d like to do is create a view that can reside on the Server that simply contains a list of each Serial_Number, the Pressure_Test result, the Pressure_Test date, the Vacuum_Test result, and the Vacuum_Test date.

If my thinking is correct, this would present less work on the Server because it would maintain this view at all times. Further, the view should execute much faster …right?

So, how would I write such a view?

If it is not faster, is there any way to get the status of the query while it is running? Displaying Cursor = Cursors.WaitCursor for 40 minutes does not instill much confidence in my application.

  • 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-24T17:34:05+00:00Added an answer on May 24, 2026 at 5:34 pm

    Not really – by default, views aren’t maintained by SQL Server – views are just SQL statement fragments that will be incorporated into your query. No performance gain here…..

    You could investigate indexed views which are indeed “maintained” in that their data values are stored on disk – just like a table.

    • Improving Performance with Indexed Views
    • Indexed views in SQL Server 2000

    They have a long laundry list of requirements and limitations – but if you match those, this could be quite a bit faster – at the price of using more disk space. You don’t get any free lunches here, either …

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

Sidebar

Related Questions

Disclaimer: This is not actually a programming question, but I feel the audience on
Disclaimer: This is for a homework assignment, but the question is not regarding the
Disclaimer This is not strictly a programming question, but most programmers soon or later
Disclaimer: I have looked through this question and this question but they both got
[DISCLAIMER: My development machine is running OS X Tiger, so my question and experiences
Disclaimer: I am a layperson currently learning to program. Never been part of a
I am trying to import data from a FoxPro database into Sql Server however
Disclaimer : I have seen the exact questions, but have not seen any answers
Disclaimer I have searched for duplicates, but I can't seem to find them. I
Disclaimer: I'm stuck on TFS and I hate it. My source control structure looks

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.