I'm working with a legacy database that stores GUID values as a varchar(36) data type:
CREATE TABLE T_Rows (
RowID VARCHAR(36) NOT NULL PRIMARY KEY,
RowValue INT NOT NULL
)
INSERT T_Rows (RowID, RowValue) VALUES (NEWID(), 1)
I would assume that storing a GUID as a uniqueidentifier would be preferable since it's only 16 bytes in size as opposed to 36.
Are there any advantages to storing a GUID as a varchar?
Perhaps only the fact that you can 'read' them from a SELECT statement (although I don't think that's particularly useful as you can use a function in a select to make Uniqueidentifiers displayable).
If the table is large, saving 20 bytes per row is considerable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With