Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random 10 Char Values
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01017716
Message ID:
01017735
Views:
16
Hi,

SQL Server does this automatically for you. Actually, the return value of NEWID() is a 16-byte value that is automatically casted to a string when you use it in a string function such as REPLACE(). If you create a uniqueidentifier field, it only consumes 16 bytes as in the following sample:

CREATE TABLE Test (ID uniqueidentifier DEFAULT NewID(), cValue varchar(30))
INSERT INTO Test (cValue) VALUES ('one')
INSERT INTO Test (cValue) VALUES ('two')
INSERT INTO Test (cValue) VALUES ('three')
SELECT * FROM Test
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform