12,406,342 members (69,037 online)
Rate this:
See more:
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 21:40pm
Maciej Los 20-Mar-13 3:45am

Please, be more specific and provide more details (for example: desired output).

Rate this:

## 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

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
```
v2
Rate this:

## Solution 2

Top Experts
Last 24hrsThis month
 OriginalGriff 306 Karthik Bangalore 194 ppolymorphe 124 BillWoodruff 115 Richard MacCutchan 105
 OriginalGriff 7,947 Karthik Bangalore 3,521 ppolymorphe 3,384 Richard MacCutchan 2,577 F-ES Sitecore 2,300