Published on: 16 Feb, 2021

How to generate new Guid in TSQL?

Tumblr Digg Google Plus

GUID stands for Globally Unique Identifier. It is a universally unique id using a pseudo-random 128-bit number. GUIDs are mostly used to replace as another alternative or replacement of integer value. It is preferable to compare with numbers because it is unique across tables, databases, and servers. The drawback is it contains 4 times larger than the traditional 4-byte index value.

To generate a GUID value in TSQL. You can use the built-in function called NEWID().

Here is the TSQL query to generate a new GUID in SQL Server.


SELECT NEWID() As GUIDVALUE

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.