13,047,502 members (60,957 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
 Graeme_Grant 132 Satya Prakash Swain 109 Richard MacCutchan 104 Kornfeld Eliyahu Peter 90 Atlapure Ambrish 70
 OriginalGriff 4,868 RickZeeland 1,904 ppolymorphe 1,748 F-ES Sitecore 1,553 Dave Kreskowiak 1,379