Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Deleted items still appears in output


Deleted items still appears in output

Author
Message
hidayah
hidayah
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 19
Hi All,

Attached is the result that I required (the line I highlighted in blue that contains the correct info that I need).

As you can see, I have tons of rows, which includes those infos from the previously deleted files.

I need to know how to exclude those infos from those deleted files from my final output.

Actually I have use the same query for my previous project, and it works just fine. Only this time that it happened this way where the infos from deleted files still appear.

By the way, it's a Windows file.
Attachments
Required Result.jpg (20 views, 321.00 KB)
hidayah
hidayah
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 19
hidayah (7/10/2013)
Hi All,

Attached is the result that I required (the line I highlighted in blue that contains the correct info that I need).

As you can see, I have tons of rows, which includes those infos from the previously deleted files.

I need to know how to exclude those infos from those deleted files from my final output.

Actually I have use the same query for my previous project, and it works just fine. Only this time that it happened this way where the infos from deleted files still appear.

By the way, it's a Windows file.


P/S: And also, the result are repetitive.
ChrisM@Work
ChrisM@Work
SSCrazy Eights
SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)SSCrazy Eights (8.9K reputation)

Group: General Forum Members
Points: 8921 Visits: 19004
hidayah (7/10/2013)
Hi All,

Attached is the result that I required (the line I highlighted in blue that contains the correct info that I need).

As you can see, I have tons of rows, which includes those infos from the previously deleted files.

I need to know how to exclude those infos from those deleted files from my final output.

Actually I have use the same query for my previous project, and it works just fine. Only this time that it happened this way where the infos from deleted files still appear.

By the way, it's a Windows file.


Unless you have a mechanism in place for reading file system information into SQL server and then updating your projects table, your results are not going to change. Without more information, all I can offer is an improvement on your query. This runs 10x faster in a simple test harness:
SELECT eav.*
FROM Projects AS P
OUTER APPLY (
   SELECT
      [Drawing Number]   = MAX(CASE WHEN v.VariableName = 'Whole Number' THEN vv.ValueText END),
      [Project Name]      = MAX(CASE WHEN v.VariableName = 'Folder Name' THEN vv.ValueText END),
      [Folder Description] = MAX(CASE WHEN v.VariableName = 'Folder Description' THEN vv.ValueText END),
      [Start Date]      = MAX(CASE WHEN v.VariableName = 'Start Date' THEN vv.ValueText END),
      [End Date]         = MAX(CASE WHEN v.VariableName = 'End Date' THEN vv.ValueText END),
      [Designer]         = MAX(CASE WHEN v.VariableName = 'Author' THEN vv.ValueText END)
   FROM VariableValue vv
   INNER JOIN Variable v ON v.VariableID = vv.VariableID
   WHERE vv.ProjectID = p.ProjectID -- CORRELATION
      AND v.VariableName IN ('Whole Number','Folder Name','Folder Description','Start Date','End Date','Author')
   GROUP BY vv.ProjectID
) eav
WHERE P.Deleted = 0



“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Mark Eckeard
Mark Eckeard
SSC-Enthusiastic
SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)

Group: General Forum Members
Points: 133 Visits: 505
We still need more information.

What data type is the column "Deleted"? Also, add it to your select query so we can see a sample of the data that it holds. Otherwise we have no way to help with the where clause to prevent these records from being returned.

Mark



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search