Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Loading two different tables onto a crystal report

Author  Topic 

degraft
Starting Member

10 Posts

Posted - 2009-03-09 : 05:48:05
Hello Gurus, I have a problem. Please kindly help me out. I have these tables
tbLongSigns(LongID,TypeID,CatID,Town,StreetAddress,ElectoralArea,Cost)
tbShortSigns(ShortID,TypeID,CatID,Town,StreetAddress,ElectoralArea,Cost)
tbApplicants(AppliID,Title,FirstName,LastName,CompanyName,PostalAddress,Tel,Fax,AccountNo,Arrears).
tbSetType(TypeID,Type) ' For the LongSigns types' .
tbSetShortType(TypeID,Type) 'For the ShortSigns types'.
I have linked the tables appropriately. Now I wish to load a report so that all the LongSigns and ShortSigns that a particular Applicant applied for under the columns
(Type,Category,Town,StreetAddress,ElectoralArea,Cost)
This is the Procedure I'm using but it returns only the records of tbLongSigns:

ALTER PROCEDURE [dbo].[spReceipt]
@ApplicantID int
AS
Select DISTINCT Title + ' ' + FirstName + ' ' + LastName As 'Contact Person',CompanyName,PostalAddress,Tel,Fax,AccountNo,Arrears,
(Select Cost From tbCosts Where SignType=COALESCE(T.Type,ST.Type) And Category=Cat.Category) As 'SignCost',
COALESCE(L.SignID,S.SignID) As 'SignID',
COALESCE(T.Type,ST.Type) As 'Type',
Category,
COALESCE(L.Town,S.Town) As 'Town',
COALESCE(L.StreetAddress,S.StreetAddress) As 'StreetAddress',
COALESCE(L.ElectoralArea,S.ElectoralArea) As 'ElectoralArea'
From tbApplicants A,tbSetCategory Cat,tbSetType T,tbSetShortType ST,tbLongSigns L,tbShortSigns S
Where A.ApplicantID = @ApplicantID
And (A.ApplicantID = L.ApplicantID And A.ApplicantID = S.ApplicantID)
And (Cat.CatID = L.CatID And Cat.CatID = S.CatID)
And (T.TypeID = L.TypeID And T.TypeID = L.TypeID)
RETURN

Please help me out. My boss is on my neck. Thanks so much in advance.


DD

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-03-09 : 11:20:55
Some sample data? If you generate CREATE TABLE scripts it gets an answer quicker.
Go to Top of Page
   

- Advertisement -