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,SanthoshPlease mark this answer as accepted answer if it resolves your problem.
Download Free E-books

SPONSORED BY

Spire.Doc - Free .NET Word API
Use Spire.Doc to create, read, write, print, and convert word documents to OpenXML, RTF, TXT, XPS, EPUB, EMF, HTML, Image and PDF.