当我运行下面的书面程序时,我得到的返回结果集就像
但实际上根据场景,我想要的是针对 @ContractId 参数的单个记录。所以,我想合并我的结果集返回的行。
PS:这张图片只显示了几列,还有一些其他的列有不同的值。
这是我的程序:
ALTER PROCEDURE [dbo].[sp_Tbl_Contract_SearchOne]
-- Add the parameters for the stored procedure here
@ContractID int
AS
BEGIN
select
tbl_Contract.ContractID,
KeyWinCountNumber,
ItemName,
BrandName,
CountName,
SellerName,
BuyerName,
ContractNumber,
ContractDate,
CountryFromName,
CountryToName,
TotalQty,
Vans,
UnitPrice,
Amount
from tbl_Contract
inner join tbl_CountDetail
on
tbl_CountDetail.ContractID = Tbl_Contract.ContractID
inner join tbl_Count tcount
on
tcount.CountID = tbl_CountDetail.CountID
INNER JOIN Tbl_Item
on Tbl_Contract.ItemID = Tbl_Item.ItemID
INNER JOIN Tbl_Brand
on Tbl_Contract.BrandID = Tbl_Brand.BrandID
INNER JOIN Tbl_Seller
on Tbl_Contract.SellerID = Tbl_Seller.SellerID
INNER JOIN Tbl_Buyer
on Tbl_Contract.BuyerID = Tbl_Buyer.BuyerID
INNER JOIN Tbl_CountryFrom
ON Tbl_Contract.CountryFromID=Tbl_CountryFrom.CountryFromID
INNER JOIN Tbl_CountryTo
ON Tbl_Contract.CountryToID = Tbl_CountryTo.CountryToID
inner join tbl_CostUnit
on Tbl_Contract.CostUnitID = tbl_CostUnit.CostUnitID
where Tbl_Contract.ContractID = 1
and Tbl_Contract.IsDeleted = 0 and tbl_CountDetail.IsDeleted = 0
END