auto increment by store procedure

Total Post:18

Points:126
 2134  View(s)
Ratings:
Rate this:

sir  i used this SP but Not autoincement

ALTER PROCEDURE dbo.AutoIncrement(@EmpName varchar(25),@Fathername varchar(25),@Address nvarchar(50),
@Phone nvarchar(12),
@Sex varchar(8),
@MaterialStatus varchar(10))
as
Declare @AEmpId int
select @AEmpId=count(EmpId)from TblEmpReg
IF(@AEmpId='0')
BEGIN
SET @AEmpId='1'
END
SELECT @AEmpId=max(@AEmpId)+1 FROM TblEmpReg
Insert into TblEmpReg(EmpId,EmpName,Fathername,Address,Phone,sex,MaterialStatus)values(@AEmpId,@EmpName,@Fathername,@Address,@Phone,@sex,@MaterialStatus)

Answer