Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Deleted items still appears in output Expand / Collapse
Author
Message
Posted Wednesday, July 10, 2013 10:27 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, September 18, 2013 5:06 AM
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.


  Post Attachments 
Required Result.jpg (20 views, 321.64 KB)
Post #1472422
Posted Wednesday, July 10, 2013 10:50 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, September 18, 2013 5:06 AM
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.
Post #1472426
Posted Thursday, July 11, 2013 1:06 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:09 AM
Points: 6,750, Visits: 13,896
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
Post #1472452
Posted Thursday, July 11, 2013 5:29 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 20, 2014 5:24 AM
Points: 128, Visits: 490
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



Post #1472511
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse