God day!I have a little problem combining in 2 tables in 1 records the result of return/exchange query I have created..Currently I have this stored proc below.ALTER PROCEDURE sp_Get_Return_Exchange@orno as varchar(10)AS SET NOCOUNT ON;select p.poref as pofrefReturn,p.productcode as pdocodeReturn,p.itemname as itemnameReturn, p.qty as QtyReturn,p.price as priceReturn ,p.net as NetReturnfrom tbl_PO_detail pwhere p.poref=@orno and p.memo='return/exchange'UNION ALLselect sd.salesid as salesidExchange,sd.productcode as pdocodeExchange,sd.productdesc as proddescExchange,sd.qty as QtyExchange,sd.srp as srpExchange ,sd.net as NetExchangefrom tbl_Sales_detail sdwhere sd.salesid=@orno and p.salestype='return/exchange'
And this is the result:poref pdocodeReturn itemname QtyReturn price NetReturn0000032 72225684478 cream milk 25g 2 25 50
I like to achieve something like where results for tbl_Sales_detail will be added on the result with is column alias name like below:poref pdocodeReturn itemname QtyReturn price NetReturn salesidExchange pdocodeExchange proddescExchange QtyExchange srpExchange NetExchange 0000032 72225684478 cream milk 25g 2 25 50 0000032 72225684479 fibered rice 1sck 2 2000 4000
Column in color red must be added on the result which is from tbl_Sales_detail table! Thank you!-------------------------------------------------------------------------------------------------------Learning MS SQL Server 2008