日期:2014-05-17 浏览次数:20403 次
if (@BasicUnit_1 != 0) and (@BasicUnit_1 != null)
begin
update ProductPrice set BasicUnit_1 = cast(FactoryPrice * @BasicUnit_1 as decimal(18,2)) where ProductID in
(select ProductID from V_Products where @strWhere)
end
if (@BasicUnit_2 != 0) and (@BasicUnit_2 != null)
begin
update ProductPrice set BasicUnit_2 = cast(FactoryPrice * @BasicUnit_2 as decimal(18,2)) where ProductID in
(select ProductID from V_Products where @strWhere)
end
CREATE PROC Test
@ParaName VARCHAR(20),
@ParaValue VARCHAR(20),
@strWhere VARCHAR(100)
AS
BEGIN
DECLARE @Sql VARCHAR(1000)
IF ISNULL(@ParaValue,'0') !='0'
BEGIN
SET @Sql='UPDATE ProductPrice SET '+@ParaName+' = CAST(FactoryPrice * '+@ParaValue+' AS DECIMAL(18,2)) '+
'WHERE ProductID IN(SELECT ProductID FROM V_Products WHERE '+@strWhere+')'
EXEC(@Sql)
END
END
if (@BasicUnit_1 != 0) and (@BasicUnit_1 != null)
begin
exec('update ProductPrice set BasicUnit_1 = cast(FactoryPrice *'+ ltrim(@BasicUnit_1)+' as decimal(18,2)) where ProductID in
(select ProductID from V_Products where '+@strWhere+'='+LTRIM(@BasicUnit_1)+')'
end
if (@BasicUnit_2 != 0) and (@BasicUnit_2 != null)
begin
exec('update ProductPrice set BasicUnit_1 = cast(FactoryPrice *'+ ltrim(@BasicUnit_2)+' as decimal(18,2)) where ProductID in
(select ProductID from V_Products where '+@strWhere+'='+LTRIM(@BasicUnit_2)+')'