Solved

BIg Fobar need Help SQL staement needed for dsign flaw

Posted on 2007-04-11
1
217 Views
Last Modified: 2010-03-19
Little bit a design flaw found i want go into it.

I need a SQL fix for some data manipulation.

Where Query1 JOBID  =   JOBID in Querry2  AND CLIENTID (Querry 1) = CompanyID (Querry2)

Then ClientID (Querry1) = SitesID in Querry 2

A total mind F**T i know Hellllpppp



Querry 1

SELECT tblDocumentRevision.DocumentRevisionID, tblCTR.JobID, tblDocumentRevision.ClientID
FROM (tblCTR INNER JOIN tblDocRegister ON tblCTR.CTRID = tblDocRegister.CtrId) INNER JOIN tblDocumentRevision ON tblDocRegister.DocID = tblDocumentRevision.DocID
WHERE (((tblDocumentRevision.ClientID) Is Not Null))
ORDER BY tblCTR.JobID;


Querry 2

SELECT tblJob.JobID, tblSites.CompanyID, tblSites.SitesID
FROM tblJob RIGHT JOIN tblSites ON tblJob.JobID = tblSites.JobID
ORDER BY tblJob.JobID;

0
Comment
Question by:ellandrd
1 Comment
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 18889638
try this

update tblDocumentRevision
set ClientID = tblSites.SitesID
from tblDocumentRevision INNER JOIN
(tblCTR INNER JOIN tblDocRegister ON tblCTR.CTRID = tblDocRegister.CtrId)
ON tblDocRegister.DocID = tblDocumentRevision.DocID
 join (tblJob RIGHT JOIN tblSites ON tblJob.JobID = tblSites.JobID)
on tblCTR.JobID = tblJob.JobID and
tblDocumentRevision.ClientID = tblSites.CompanyID
where tblDocumentRevision.ClientID Is Not Null
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unable to save view in SSMS 21 61
MSSQL: Replace text (typo) 7 34
SQL Server stored proc 2 14
SQL Query with WHERE clause for an entire day 5 23
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now