Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,

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
Posted
Comments
Maciej Los 20-Mar-13 3:45am    
Please, be more specific and provide more details (for example: desired output).

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)						

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]	

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

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
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900