USE [temp]GO/****** Object: Table [dbo].[TblTest] ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[TblTest]( [temp_id] [int] IDENTITY(1,1) NOT NULL, [temp_name] [varchar](50) NULL, [sum] [int] NULL, [Total_sum] [int] NULL) ON [PRIMARY]GOSET ANSI_PADDING OFF
Alter procedure ProcTestGet@temp_name varchar(50),@sum intAS Declare @Tmp_id As int Declare @total_sum As int Declare @sum1 As intselect @Tmp_id = @@identityIf @Tmp_id = 0 Begin set @total_sum =Null insert into TblTest(temp_name,sum,total_sum) VALUES(@temp_name,@sum,@total_sum)End elsebegin select @total_sum = total_sum from TblTest where temp_id = @@identity if @total_sum = NULL begin select @sum1= sum from TblTest where temp_id = @@identity declare @totalsum int set @totalsum = @sum1 + @sum insert into TblTest(temp_name,sum,total_sum) VALUES(@temp_name,@sum,@totalsum) end else begin select @total_sum = total_sum from TblTest where temp_id = @@identity declare @totalsum1 int set @totalsum1 = @total_sum + @sum insert into TblTest(temp_name,sum,total_sum) VALUES(@temp_name,@sum,@totalsum1) endselect @@identityEnd
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: