Generate a new 32-bit GUID in C # and SQL Server

Source: Internet
Author: User

Use Guid.NewGuid () in C #. ToString ()

SQL with NEWID ()

The above method generates a 36-bit GUID, which needs to be replaced with the '-' character if it needs to be converted to 32-bit.

Methods in sql: replace (NEWID (), '-', ')

------------------------------------------

A GUID (global uniform identifier) is a number generated on a machine that guarantees that all machines in the same time and space are unique. Typically, the platform provides the API to generate the GUID. The generation algorithm is interesting, using the Ethernet card address, nanosecond time, chip ID code and many possible numbers. The only drawback to the GUID is that the resulting string will be larger. ”
1. A GUID is a 128-bit integer (16 bytes), and in the case of a unique identifier, you can use this integer between all computers and networks.
The format for 2.GUID is "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", where each x is a hexadecimal number in the range of 0-9 or a-f. For example, 337C7F2B-7A34-4F50-9141-BAB9E6478CC8 is a valid GUID value.
3. No two computers in the world (Koffer Note: should be on earth) will generate duplicate GUID values. GUIDs are primarily used to assign identifiers that must be unique in a network or system that has multiple nodes, multiple computers, and more than one computer.
4. On the Windows platform, GUIDs are widely used: Registry, class and interface identifiers, databases, even automatically generated machine names, directory names, and so on.

Turn:

Fei Qi Source: http://youring2.cnblogs.com/statement: The original text of this blog only represents my work in a certain time to summarize the views or conclusions, and I do not have a direct interest in the unit. Non-commercial, unauthorized, post please keep the status quo, reprint must retain this paragraph statement, and in the article page obvious location to the original connection.

Generate a new 32-bit GUID in C # and SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.