如何为信用率创建存储过程? [英] how to create stored procedure for credit rate?
本文介绍了如何为信用率创建存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建函数来获取SQL中的信用计算,它现在正常工作我需要创建存储过程,如果我只给出点击价值输入自动返回实际信用值。
任何人都可以帮助我。
I am creating the function to get credit calculation in SQL,its working properly now I need to create stored procedure ,like If I give only clicks value input automatically return the actual credit value .
can anyone help me .
GO
declare @clicks bigint = 500
declare @creditPoint float = .15
declare @actualCredits MONEY = @clicks*.15
select @clicks as CLICKS
select @creditPoint as CREDIT_POINT
select @actualCredits as ACTUAL_CREDITS
GO
推荐答案
CREATE TABLE [cpqaAnswers].[cpqa].[tbl_SM_CreditInfo](
[IDX][int]IDENTITY(1,1),
[CLICKS][bigint],
[CREDIT_POINT][float],
[ACTUAL_CREDITS][money]
)
通常,要表格数据:
Normally, to table the data:
INSERT INTO [cpqaAnswers].[cpqa].[tbl_SM_CreditInfo]
VALUES(500,0.15,500*0.15)
但我们将使用stoproc来做同样的事情。这里是SELECT,看看表格是否正确创建:
But we''re going to be using a stoproc to do the same. Here''s the SELECT to see that the table gets created properly:
SELECT * FROM [cpqaAnswers].[cpqa].[tbl_SM_CreditInfo]
现在sp_:
And now the sp_:
USE [cpqaAnswers]
GO
CREATE PROCEDURE [cpqa].[sp_SM_updateCreditInfo]
@clicks [bigint],
@creditPoint [float],
@actualCredits [money]
AS
BEGIN
INSERT INTO [cpqaAnswers].[cpqa].[tbl_SM_CreditInfo]
VALUES(@clicks,@creditPoint,@actualCredits)
END
从TSQL脚本运行stoproc:
To run the stoproc from TSQL script:
DECLARE @clicks [bigint]
DECLARE @creditPoint [float]
DECLARE @actualCredits [money]
SET @clicks = 500
SET @creditPoint = 0.15
SET @actualCredits = @clicks*0.15
EXEC [cpqa].[sp_SM_updateCreditInfo] @clicks, @creditPoint, @actualCredits
查看我过去的答案:存储过程C# - 如果EXISTS UPDATE ELSE INSERT [ ^ ]
See my past answer: Stored Procedure C# - "IF EXISTS UPDATE ELSE INSERT"[^]
这篇关于如何为信用率创建存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文