I Create a Store Procedure
I want to getting data some different table and I use a Sub Query,
I run store procedure and store procedure run successfully and i execute a store procedure then error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
i tried the following sp
insert into @MyTableVar(TinNo,CardName,Address,DocCode,DocumentDate,TaxCategoryDescription,TotalBtax,Partnertax ,Partnertaxsurcharge )
select ISNULL((select TinNo from BP.BPTAX where CardCode=H.CardCode),'NA'),H.CardName,H.ShipToAddress,
H.DocCode,H.DocumentDate,ISNULL((select FkTaxCategoryDescription from SD.ARTXM where DocCode=H.DocCode ),'NA')
ISNULL((select sum(TotalBTax) from sd.ARDTL where DocCode=H.DocCode ),0.00),
ISNULL((select PartnerTaxSum from sd.ARTXM where FKTaxDescription like'%TAX%' and DocCode=H.DocCode ),0.00),
ISNULL((select PartnerTaxSum from sd.ARTXM where FKTaxDescription='%Surcharge%' and DocCode=H.DocCode ),0.00)
from SD.ARHDR H
where(( @FromDate is null or @ToDate is null) or (H.PostingDate >= Convert(datetime,@FromDate) and H.PostingDate<=Convert(datetime,@ToDate)))
and (@CardCode is null or H.CardCode=@CardCode)
and (@DocCode is null or H.DocCode=@DocCode)
and(@Status is null or H.Status=@Status)
group by CardCode,CardName,ShipToAddress,H.DocCode,DocumentDate,H.ModTime
I want data in this form
Tinno, cardname, shiptoaddress,DocCode,Document Date,FKTaxCategoryDescription,TotalBtax,PartnertaxSum,PartnertaxSurcharge,
PartnertaxSum,PartnertaxSurchargeas field get the one column