Tip: The project group has a basic information field to modify the product but sometimes the incoming field may or may not be empty dynamically modify the fields in the table.
1 Use [betaproductmarket_db]2 GO3 IF(EXISTS(SELECT * fromDbo.sysobjectsWHEREId=object_id(N'[dbo]. [Usp_saveproductbaseinfo]') and ObjectProperty(ID, N'isprocedure')= 1))4 BEGIN5 DROP PROCEDURE [dbo]. Usp_saveproductbaseinfo6 END7 GO8 9 /*Ten Author: Roni One function: Modify product basic information A creation time: 2016-5-24 - - Summary: the - */ - - CREATE PROCEDURE [dbo]. Usp_saveproductbaseinfo + - @ProductID INT, + @ProductType TINYINT=0, A @ProductName VARCHAR( $)=NULL , at @RecommendIndex TINYINT=0 , - @Issuer VARCHAR( $)=NULL, - @Period TINYINT=0 , - @Movement VARCHAR( -)=NULL , - @InvestmentDirection TINYINT=7, - @YieldsFixed DECIMAL( -,4)=0 , in @YieldsFloat DECIMAL( -,4)=0 , - @YieldsType TINYINT=0 , to @Amount DECIMAL( -,4)=0 + - as the * BEGIN $ Panax Notoginseng - UPDATEtb_product the SETUpdateTime=GETDATE(), +ProductName= Case when @ProductName is NULL ThenTb_product.productnameELSE @ProductName END , AProductType= Case when @ProductType=0 ThenTb_product.producttypeELSE @ProductType END , theRecommendindex= Case when @RecommendIndex =0 ThenTb_product.recommendindexELSE @ProductType END , +Issuer= Case when @Issuer is NULL ThenTb_product.issuerELSE @Issuer END , -Period= Case when @Period=0 ThenTb_product.periodELSE @Period END , $Movement= Case when @Movement is NULL ThenTb_product.movementELSE @Movement END , $Investmentdirection= Case when @InvestmentDirection=7 ThenTb_product.investmentdirectionELSE @InvestmentDirection END , -Yieldsfixed= Case when @YieldsFixed=0 ThenTb_product.yieldsfixedELSE @YieldsFixed END , -Yieldsfloat= Case when @YieldsFloat=0 ThenTb_product.yieldsfloatELSE @YieldsFloat END , theYieldstype= Case when @YieldsType=0 ThenTb_product.yieldstypeELSE @YieldsType END , -Amount= Case when @Amount=0 ThenTb_product.amountELSE @Amount END Wuyi WHEREProductID= @ProductID the - Wu - About $ - END
SQL Dynamic Update table field incoming fields may be empty