How to automatically generate unique id in sql?

In sql there are many options to generate unique number. Here I am explaining about how to generate standard unique number in sql.

Below is sql query :

CREATE TABLE dbo.tblTable1
  (ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
   UserID AS UID + RIGHT(00000000 + CAST(ID AS VARCHAR(8)), 8) PERSISTED,
   username varchar(200),city varchar(200)
  )

Popular posts from this blog

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

Calling ASP.Net WebMethod using jQuery AJAX