cant save ReturnIDcount in database table .
ALTER PROCEDURE [dbo].[Transaction]
(
@Patient nvarchar(50),
@E_TO nvarchar(50),
@R_type int,
@User_name nvarchar(50),
@ReportType int,
@Patient_no int,
@Patient_ID_NO numeric(18,0),
@ReturnIDcount nvarchar(50) output
)
AS
BEGIN
declare @idcount numeric(18,0)
declare @tempid numeric(18,0)
set @tempid = 0;
declare @idcnt numeric(18,0)
select @idcnt =isnull( max(idcount),0) from Transactions where year(R_date)=year(getdate())
if (@idcnt =0)
set @tempid=1
else
set @tempid = @idcnt +1
INSERT INTO dbo.Transactions (Patient,E_TO,R_date,R_from,User_name,report_type,Patient_no,Patient_ID_NO,idcount)
values
(@Patient,@E_TO,getdate(),@R_type,@User_name,@ReportType,@Patient_no,@Patient_ID_NO,@tempid)
select @idcount =isnull( max(idcount),0) from Transactions where year(R_date)=year(getdate())
set @ReturnIDcount = '301A' + cast( @idcount as varchar)
return @ReturnIDcount
END