I am using Query Analyzer in SQL Server 7 to Create a View that uses fields in a database called SEM5 and also, a couple of "Name" fields in a second database called CoreData ,located on the same (local) server. It appears to me that the UNION staments and the SELECTs following them are not being recognized. Here is the code:
CREATE VIEW dbo.vu_ServicesReport (StudentID, IEPReason, OriginalIEPDate, ServiceID, Amount, Frequency, Location, BeginDate, EndDate, TeacherID, CDStudentID, StudentName, CDTeacherID, TeacherName )AS
SELECT SEM5.dbo.tblStdtIEPServicesSum.StudentID AS StudentID,
SEM5.dbo.tblStdtIEPServicesSum.IEPReason AS IEPReason,
SEM5.dbo.tblStdtIEPServicesSum.OriginalIEPDate AS OriginalIEPDate,
SEM5.dbo.tblStdtIEPServicesSum.ServiceID AS ServiceID,
SEM5.dbo.tblStdtIEPServicesSum.ServiceDesc AS ServiceDesc,
SEM5.dbo.tblStdtIEPServicesSum.Amount AS Amount,
SEM5.dbo.tblStdtIEPServicesSum.Frequency AS Frequency,
SEM5.dbo.tblStdtIEPServicesSum.Location AS Location,
SEM5.dbo.tblStdtIEPServicesSum.BeginDate AS BeginDate,
SEM5.dbo.tblStdtIEPServicesSum.TeacherID AS TeacherID
FROM SEM5.dbo.tblStdtIEPServicesSum
UNION
SELECT CoreData.dbo.tblStdtPersonal.StudentID AS CDStudentID,
CoreData.dbo.tblStdtPersonal.FullName AS StudentName FROM CoreData.dbo.tblStdtPersonal
UNION
SELECT CoreData.dbo.tblTeacherPersonal.TeacherID AS CDTeacherID,
CoreData.dbo.tblTeacherPersonal.FullName AS TeacherName FROM CoreData.dbo.tblTeacherPersonal
Parsing gives a "Good" indication. Execution generated the following message:
Server: Msg 8159, Level 16, State 1, Procedure vu_ServicesReport, Line 2
'vu_ServicesReport' has fewer columns than were specified in the column list.
I have checked all the documentation that I can find and tried all the variations that I can think of with basically the same results. I suspect there is something that I am simply not seeing, maybe while I am looking right at it.
Any one see any thing that I don't?
TIA
Ralph
TIA
Ralph D. Meredith
CREATE VIEW dbo.vu_ServicesReport (StudentID, IEPReason, OriginalIEPDate, ServiceID, Amount, Frequency, Location, BeginDate, EndDate, TeacherID, CDStudentID, StudentName, CDTeacherID, TeacherName )AS
SELECT SEM5.dbo.tblStdtIEPServicesSum.StudentID AS StudentID,
SEM5.dbo.tblStdtIEPServicesSum.IEPReason AS IEPReason,
SEM5.dbo.tblStdtIEPServicesSum.OriginalIEPDate AS OriginalIEPDate,
SEM5.dbo.tblStdtIEPServicesSum.ServiceID AS ServiceID,
SEM5.dbo.tblStdtIEPServicesSum.ServiceDesc AS ServiceDesc,
SEM5.dbo.tblStdtIEPServicesSum.Amount AS Amount,
SEM5.dbo.tblStdtIEPServicesSum.Frequency AS Frequency,
SEM5.dbo.tblStdtIEPServicesSum.Location AS Location,
SEM5.dbo.tblStdtIEPServicesSum.BeginDate AS BeginDate,
SEM5.dbo.tblStdtIEPServicesSum.TeacherID AS TeacherID
FROM SEM5.dbo.tblStdtIEPServicesSum
UNION
SELECT CoreData.dbo.tblStdtPersonal.StudentID AS CDStudentID,
CoreData.dbo.tblStdtPersonal.FullName AS StudentName FROM CoreData.dbo.tblStdtPersonal
UNION
SELECT CoreData.dbo.tblTeacherPersonal.TeacherID AS CDTeacherID,
CoreData.dbo.tblTeacherPersonal.FullName AS TeacherName FROM CoreData.dbo.tblTeacherPersonal
Parsing gives a "Good" indication. Execution generated the following message:
Server: Msg 8159, Level 16, State 1, Procedure vu_ServicesReport, Line 2
'vu_ServicesReport' has fewer columns than were specified in the column list.
I have checked all the documentation that I can find and tried all the variations that I can think of with basically the same results. I suspect there is something that I am simply not seeing, maybe while I am looking right at it.
Any one see any thing that I don't?
TIA
Ralph
TIA
Ralph D. Meredith