I have a parent table that has a primary key of RequestID. I have 4 other tables that use the Request ID as a foreign key. Unfortunately during testing some records were entered into the parent table but subsequent records were not entered into any of the other tables. The way I originally had the stored procedure written it was returning all records in the parent table but now that is a problem since there aren't matching records. What I want is to return only the records that have records in the other tables. I tried doing multiple INNER JOINS and now it doesn't return any records.
This is what I tried but it doesn't return any records:
CREATE VIEW dbo.vSelectServiceLog
AS
SELECT TOP 100 PERCENT dbo.ServiceRequests.RequestID, dbo.ServiceRequests.Status, dbo.ServiceRequests.DateSent, dbo.ServiceRequests.ChangedBy, dbo.ServiceRequests.JurID,
dbo.Jurisdictions.FirstName + ' ' + dbo.Jurisdictions.LastName AS WRIBCoordinator
FROM dbo.ServiceRequests INNER JOIN
dbo.Jurisdictions ON dbo.ServiceRequests.JurID = dbo.Jurisdictions.JurID INNER JOIN
dbo.ReviewDraft ON dbo.ServiceRequests.RequestID = dbo.ReviewDraft.RequestID INNER JOIN
dbo.BookletMaster ON dbo.ServiceRequests.RequestID = dbo.BookletMaster.RequestID INNER JOIN
dbo.Scoring ON dbo.ServiceRequests.RequestID = dbo.Scoring.RequestID INNER JOIN
dbo.Feedback ON dbo.ServiceRequests.RequestID = dbo.Feedback.RequestID
Parent Table - ServiceRequests
Child Tables - ReviewDraft, BookletMaster, Scoring, Feedback
The Jurisdictions table doesn't contain any of the RequestID records. It is only to retrieve the Jurisdiction information.
I even tried another angle by trying the following but I got a lot of errors when I tried to save it:
SELECT dbo.ReviewDraft.RequestID, dbo.BookletMaster.RequestID, dbo.Scoring.RequestID, dbo.Feedback.RequestID, dbo.ServiceRequests.TestID, dbo.ServiceRequests.Status, dbo.ServiceRequests.StatusDate,
dbo.ServiceRequests.DateReceived, dbo.ServiceRequests.JurID, dbo.ServiceRequests.ReqType, dbo.ServiceRequests.DateNeeded,
dbo.ServiceRequests.DateSent, dbo.ServiceRequests.ChangedBy
WHERE dbo.ReviewDraft.RequestID = dbo.ServiceRequests.RequestID AND
dbo.BookletMaster.RequestID = dbo.ServiceRequests.RequestID AND
dbo.Scoring.RequestID = dbo.ServiceRequests.RequestID AND
dbo.Feedback.RequestID = dbo.ServiceRequests.RequestID
Can anyone help me?
This is what I tried but it doesn't return any records:
CREATE VIEW dbo.vSelectServiceLog
AS
SELECT TOP 100 PERCENT dbo.ServiceRequests.RequestID, dbo.ServiceRequests.Status, dbo.ServiceRequests.DateSent, dbo.ServiceRequests.ChangedBy, dbo.ServiceRequests.JurID,
dbo.Jurisdictions.FirstName + ' ' + dbo.Jurisdictions.LastName AS WRIBCoordinator
FROM dbo.ServiceRequests INNER JOIN
dbo.Jurisdictions ON dbo.ServiceRequests.JurID = dbo.Jurisdictions.JurID INNER JOIN
dbo.ReviewDraft ON dbo.ServiceRequests.RequestID = dbo.ReviewDraft.RequestID INNER JOIN
dbo.BookletMaster ON dbo.ServiceRequests.RequestID = dbo.BookletMaster.RequestID INNER JOIN
dbo.Scoring ON dbo.ServiceRequests.RequestID = dbo.Scoring.RequestID INNER JOIN
dbo.Feedback ON dbo.ServiceRequests.RequestID = dbo.Feedback.RequestID
Parent Table - ServiceRequests
Child Tables - ReviewDraft, BookletMaster, Scoring, Feedback
The Jurisdictions table doesn't contain any of the RequestID records. It is only to retrieve the Jurisdiction information.
I even tried another angle by trying the following but I got a lot of errors when I tried to save it:
SELECT dbo.ReviewDraft.RequestID, dbo.BookletMaster.RequestID, dbo.Scoring.RequestID, dbo.Feedback.RequestID, dbo.ServiceRequests.TestID, dbo.ServiceRequests.Status, dbo.ServiceRequests.StatusDate,
dbo.ServiceRequests.DateReceived, dbo.ServiceRequests.JurID, dbo.ServiceRequests.ReqType, dbo.ServiceRequests.DateNeeded,
dbo.ServiceRequests.DateSent, dbo.ServiceRequests.ChangedBy
WHERE dbo.ReviewDraft.RequestID = dbo.ServiceRequests.RequestID AND
dbo.BookletMaster.RequestID = dbo.ServiceRequests.RequestID AND
dbo.Scoring.RequestID = dbo.ServiceRequests.RequestID AND
dbo.Feedback.RequestID = dbo.ServiceRequests.RequestID
Can anyone help me?