Generate Unique ID in C#.Net and SqlServer. To Generate UniqueID in C#.Net: Guid.NewGuid() method will be useful to Achieve the task, It generates 36 character UniqueID. Example: Guid guid = Guid .NewGuid(); string StrID = guid.ToString(); To Generate UniqueID in Sql Server 2008: newid() in build function will be useful to Achieve the task, It genrates 36 character UniqueID. Example: select newid() as UniqueID