I am using the standard ASP.NET Membership table structure in SQL Server and was doing a bit of manually querying in Management studio and ran this query
SELECT *
FROM [aspnet_Users]
WHERE UserId = '2ac5dd56-2630-406a-9fb8-d4445bc781da&cID=49'
Notice the &cID=49 at the end - I copied this from a querystring and forgot to remove that part.
However, to my surprise it returned the data correctly (there is a user with the ID 2ac5dd56-2630-406a-9fb8-d4445bc781da) - any idea why this works? To my mind it should not match or probably more likely throw an error as it shouldn't be able to convert to a Guid?
The uniqueidentifier
type is considered a character type for the purposes of conversion from a character expression, and therefore is subject to the truncation rules for converting to a character type. That is, when character expressions are converted to a character data type of a different size, values that are too long for the new data type are truncated.
Because the uniqueidentifier type is limited to 36 characters, the characters that exceed that length are truncated.
Note that above is quoted from MSDN
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