为什么我的.xsd数据集显示1个查询的列而不显示其他2个查询?
我在我的存储过程中使用了3个查询,并在我的数据集中用于RDLC报告,但它确实只显示第一个查询的列而不显示其他查询。
我的SP:
create PROC [dbo].[SelectContractorsBio]
@GC_ID INT
AS
BEGIN
Select c.Name, c.FatherName, c.Farm, cat.Name 'Cat', c.CNIC, c.EnlistmentNo, c.ContactNo,
CONVERT(date,c.RegistrationDate,106) as RegistrationDate, c.Email, pcat.Name 'PECCat', c.PECCategoryNo 'PECLicenseNo',
c.PECReceiptNo, c.ExpectedDate, c.CNWEnlistmentNo, c.NTN, cr.BankName, cr.BankCode, cr.BankDraftNo,
cat.Fee, cat.Amount, c.Address, Case when c.HasTaxExempted = 1 then 'Yes' else 'No' end
from Contractors c
Inner Join Category cat
ON Cat.ID= c.ContractorType_ID
Inner Join ContractorRenewal cr
ON cr.Contractor_ID= c.ContractorID
Inner Join PecCategories pcat
ON pcat.ID= c.PECCategoryID
Select Documents.DocumentID, Documents.Name from DocumentContractor dc
Inner Join Documents
ON Documents.DocumentID= dc.Doc_ID
where dc.Contractor_ID= @GC_ID
Select sc.SpecializationID, sc.Name 'SpecializationName', sc.SpecializationCode, spc.Contractor_ID from SpecializationCodes sc
INNER JOIN SpecializationCodeContractor spc
ON sc.SpecializationID= spc.SP_ID
END
数据集:
答案 0 :(得分:0)
存储过程不能输出多个结果集,因此您只能从第一个查询中获得结果。
如果您需要来自所有查询的数据,则需要将其整合到一个查询...
<!-- language: lang-sql -->
SELECT c.Name
,c.FatherName
,c.Farm
,cat.Name AS 'Cat'
,c.CNIC
,c.EnlistmentNo
,c.ContactNo
,CONVERT(DATE,c.RegistrationDate,106) AS RegistrationDate
,c.Email
,pcat.Name AS 'PECCat'
,c.PECCategoryNo AS 'PECLicenseNo'
,c.PECReceiptNo
,c.ExpectedDate
,c.CNWEnlistmentNo
,c.NTN
,cr.BankName
,cr.BankCode
,cr.BankDraftNo
,cat.Fee
,cat.Amount
,c.Address
,CASE WHEN c.HasTaxExempted = 1
THEN 'Yes'
ELSE 'No'
END AS 'HasTaxExempted'
,doc.DocumentId
,doc.[Name] AS DocumentName
,sc.SpecializationID
,sc.[Name] AS SpecializationName
,sc.SpecializationCode
,c.ContractorID
FROM Contractors AS c
INNER JOIN [Category] AS cat
ON cat.ID = c.ContractorType_ID
INNER JOIN ContractorRenewal AS cr
ON cr.Contractor_ID = c.ContractorID
INNER JOIN PecCategories AS pcat
ON pcat.ID = c.PECCategoryID
-- Using LEFT OUTER JOIN, in case you have no data
LEFT OUTER JOIN DocumentContractor AS dc
ON dc.Contractor_ID = c.ContractorID
INNER JOIN Documents AS doc
ON doc.DocumentId = dc.Doc_ID
-- Using LEFT OUTER JOIN, in case you have no data
LEFT OUTER JOIN SpecializationCodeContractor AS scc
ON scc.Contractor_ID = c.ContractorId
INNER JOIN SpecializationCodes AS sc
ON sc.SpecializationID = scc.SP_ID;