---
title: "auto increment  by store procedure"  
description: "auto increment  by store procedure"  
author: "Pawan kumar"  
published: 2011-03-14  
updated: 2011-03-15  
canonical: https://www.mindstick.com/forum/193/auto-increment-by-store-procedure  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# auto increment  by store procedure

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))asDeclare @AEmpId intselect @AEmpId=count(EmpId)from TblEmpRegIF(@AEmpId='0')BEGIN SET @AEmpId='1'ENDSELECT @AEmpId=max(@AEmpId)+1 FROM TblEmpRegInsert into TblEmpReg(EmpId,EmpName,Fathername,Address,Phone,sex,MaterialStatus)values(@AEmpId,@EmpName,@Fathername,@Address,@Phone,@sex,@MaterialStatus)
```

## Replies

### Reply by Anonymous User

Hello Pawan.

Please check this link. This might be useful for you.

http://www.mindstick.com/Blog/133/Auto%20increment%20id%20by%20using%20stored%20procedure


---

Original Source: https://www.mindstick.com/forum/193/auto-increment-by-store-procedure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
