Forum guidelines
  • Home
  • »
  • SQL Server
  • »
  • How can we set auto increment value of primary key through query
AuthorQuestion
How can we set auto increment value of primary key through query
Posted By Shubham Srivastava on 26 Jul 2012
How can we set auto increment value of primary key through query ?

AuthorReply
Re: How can we set auto increment value of primary key through query
Posted By Santhosh Kumar Jayaraman on 26 Jul 2012  
declare @key int
Select @key=Isnull(MAX(UseriD),0)+1 from tbl_user
insert into tbl_user values(@key,'username','xxxxx')

Thanks & Regards,
Santhosh

Please mark this answer as accepted answer if it resolves your problem.

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.