Labels

slider

Recent

Navigation

Guid in SQL

guid in sql, guid in c#, guid in c# example, guid in sql server, guid in sql server 2012

Introduction

GUID is generated to unique identifier No. GUID is created through network card.
SQL Server have data type uniqueidentifier, A sample database snapshot has been provided below: 

uniqueidentifier
Guid in SQL

--Code snippet shwoing uniqueidentifier in a variable
DECLARE @TechnologyCrowdsID uniqueidentifier
SET @TechnologyCrowdsID = NEWID()
SELECT @TechnologyCrowdsID


We can generate uniqueidentifier using NEWID() in SQL, I have provided code snippet below:

SELECT NEWID()

SELECT NEWID()

Above code sample shows best example of  Guid in SQL

I have provided C# code snippet to generate following:
Namespace using System

using System;

class TechnologyCrowds 
{
    public static void Main() 
    {
    Guid Gtc;
   // Create and display the value of two GUIDs.
    Gtc = Guid.NewGuid();
    Console.WriteLine(Gtc);
    Console.WriteLine(Guid.NewGuid());
    }
}

/*
Above code example will produce the below results:
0D1C39FA-D58D-4C4D-A910-33A07116CB89
B1CB4977-AD8C-4D11-8D87-87F471A319F7
*/

Suggested Reading

Share

Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:

0 comments: