Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 19-Mar-13 22:40pm
Comments
Maciej Los at 20-Mar-13 3:45am
   
Please, be more specific and provide more details (for example: desired output).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  

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

  Print Answers RSS
0 OriginalGriff 381
1 Praneet Nadkar 237
2 Marcin Kozub 225
3 Sergey Alexandrovich Kryukov 195
4 Shweta N Mishra 161
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100