Roughly as follows:
The create PROC _proc_ actual value calculation
@ A DECIMAL (18, 2),
@ B a DECIMAL (18, 2),
@ C a DECIMAL (18, 2),
@ D a DECIMAL (18, 2),
@ E DECIMAL (18, 2),
@ formula NVARCHAR (50)
AS
The BEGIN
//according to the formula of the incoming text content and value, and the results of
END
GO
//the first may
EXEC dbo. _proc_ actual value calculation @ A=1,
@ B=50000,
@ C=NULL,
@ D=NULL,
@ E=NULL,
@ formula='@/@ B * 80000'
//the second may
Exec dbo. _proc_ actual value calculation @ A=1,
@ B=null,
@ C=NULL,
@ D=NULL,
@ E=NULL,
@ formula='CASE when @ A>=1 THEN 0 ELSE NULL END '
Also which help me inform the trouble.
CodePudding user response:
CREATE PROCEDURE FORMULA
(@ A DECIMAL (18, 2),
@ B a DECIMAL (18, 2),
@ C a DECIMAL (18, 2),
@ D a DECIMAL (18, 2),
@ E DECIMAL (18, 2),
@formula NVARCHAR (50))
AS
The BEGIN
DECLARE @ FORMULA_NEW NVARCHAR (100)
SET @ FORMULA_NEW='SELECT' + @formula + 'AS the RESULT of'
IF the @ IS NOT NULL AND @ B IS NOT NULL
The BEGIN
The EXEC SP_EXECUTESQL @ FORMULA_NEW, N '@ A DECIMAL (12, 13), @ B A DECIMAL (12, 13)', A, @ A=@ @ B=@ B
END
IF the @ IS NOT NULL AND @ B IS NULL
The BEGIN
The EXEC SP_EXECUTESQL @ FORMULA_NEW, N '@ A DECIMAL (12, 13)', @ A=@ A
END
END