日期:2014-05-17 浏览次数:20445 次
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
--根据辅料名ID和采购单号查询采购单 总表
ALTER proc [dbo].[ERP_GetNumToAccessoryM]
@No varchar(50),
@T_AccessoryMaterialName_ID varchar(50)
as
declare @s varchar(8000)
set @s='select
(select Detail from T_SecondaryMaterialData where Id =T_OrderAccessoryNotice.T_SecondaryMaterialData_ID) as ''描述'',
Color as ''顏色'',
Color as ''染廠色號'',
Color as ''規格/型號'''
select @s=@s+', '''+BackUp2+''' =Max(case BackUp2 when '''+BackUp2+''' then Quantity
else '''' end)'
from T_OrderAccessoryNotice where [No]=@No and T_AccessoryMaterialName_ID=@T_AccessoryMaterialName_ID
exec(@s+',TransformUnit,sum(convert(float,Quantity)) as 總數,Price as 單價 ,(select distinct Taxrate from T_AccessoryQuoteRatify where MaterialName=(select MaterialName from T_AccessoryMaterialName where ID = T_OrderAccessoryNotice.T_AccessoryMaterialName_ID)) as 稅率 ,Remark as 備註 from T_OrderAccessoryNotice where [No]='''+@No+''' and T_AccessoryMaterialName_ID = '''+ @T_AccessoryMaterialName_ID +'''
group by Color,Price, T_OrderAccessoryNotice.T_AccessoryMaterialName_ID,TransformUnit,Remark,T_OrderAccessoryNotice.T_SecondaryMaterialData_ID')
exec [ERP_GetNumToAccessoryM] '20121101000','2887'
求多条数据或单挑数据的解决办法。
ALTER PROC [dbo].[ERP_GetNumToAccessoryM]
@No VARCHAR(50)