我的情景如下:
我有一张资料表,如下所示
ProfileID int
FirstName varchar(50)
LastName varchar(100)
DateOfBirthDay varchar(100)
DateOfBirthMonth varchar(100)
DateOfBirthYear varchar(100)
Gender varchar(100)
Address1 varchar(100)
Address2 varchar(100)
City varchar(100)
Province varchar(100)
PostalCode varchar(100)
PhoneNumber varchar(100)
WorkNumber varchar(100)
CellNumber varchar(100)
EmailAddress varchar(100)
我还有表格来存储每个配置文件的不同条件,如下所示:
ProfileId int
CurrentWeight float
HeightUnit varchar(50)
CurrentHeight float
Occupation varchar(50)
Conditions varchar(MAX)
Medications varchar(MAX)
Is_Pregnant bit
Diseases varchar(MAX)
Allergy_Food varchar(MAX)
Supplements_Taken varchar(MAX)
Programs_Attended varchar(MAX)
Knowledge_Source varchar(MAX)
DateOfPhysicalExam datetime
MoreInformation varchar(MAX)
为此表中的每条记录存储数据,如下所示:(样本)
False 10,12, 119, 138, 145,147,149,
它只是将条件ID的id存储为逗号分隔值。有一个主表存储与每个id关联的值,如下所示:
5 1 Conditions Organ transplant
6 1 Conditions Recent heart attack (within the last 6 months) A
7 1 Conditions Recent stroke (within the last 6 months) A
8 2 Medications Adderral
9 2 Medications Aptivus Aptivus A
10 2 Medications Atripla Atripla A
11 2 Medications Chloramphenicol
12 2 Medications Coumadin
13 2 Medications Crixivan
.................................
现在我需要使用存储过程创建一个报告来获取每个客户资料以及条件,药物等....格式如下:
id Name Age Occupation Diseases Medications Is_Preg Supplements_Taken
10001 TestName 59 Office Asthma, Blood Pressure Heparin, Aptivus, Indocin False
我该怎么做?