Hi ROHIT,
You can't alter the existing columns for identity.
You have 2 options.
1. Create a new table with identity & drop the existing table.
2. Create a new column with identity & drop the existing column.
Check the below example.
SQL
CREATE TABLE Books
(
ID INT,
Name VARCHAR(50)
)
INSERT INTO Books VALUES(1,'SQL Server')
INSERT INTO Books VALUES(2,'ASP.NET')
INSERT INTO Books VALUES(4,'C#')
CREATE TABLE Tmp_Books
(
Id int NOT NULL IDENTITY(1,1),
Name varchar(50) NULL
) ON [PRIMARY]
GO
SET IDENTITY_INSERT Tmp_Books ON
GO
IF EXISTS(SELECT * FROM Books)
INSERT INTO Tmp_Books(Id, Name)
SELECT Id,Name FROM Books TABLOCKX
GO
SET IDENTITY_INSERT Tmp_Books OFF
GO
DROP TABLE Books
GO
EXEC sp_rename 'Tmp_Books', 'Books'
ALTER TABLE Books
ADD Id_new Int Identity(1,1)
GO
ALTER TABLE Books
DROP COLUMN ID
GO
EXEC sp_rename 'Books.Id_new', 'ID','Column'
Create a stored procedure with the query and call the stored procedure in code.
For calling stored procedure in code behind refer below article.