Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Conversion failed when converting from a character string to uniqueidentifier.How to handle this error
Posted
Updated 22-Aug-22 1:26am

Conversion failed when converting from a character string to uniqueidentifier.
This error message appears when you try to convert an invalid character string to uniqueidentifier.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity level 16 are generated by the user and are corrigible by the user. The statement cannot be run this way. Only valid character strings can be converted to uniqueidentifier.

Provide your code where you got this error to resolve it.
 
Share this answer
 
Comments
shriti 3 7-Jun-12 1:49am    
Select MediaAlbumId from dbo.MediaAlbums where Guid='0f86759f-db8d-47dd-b862-8500afc1bf7e666'

When i enter anything wrong in Guid like i put vvvv in Guid than it gives error
"Conversion failed when converting from a character string to uniqueidentifier."
Manas Bhardwaj 12-Jun-12 2:08am    
correct +5!
Prasad_Kulkarni 12-Jun-12 3:48am    
Thank you Manas!
'0f86759f-db8d-47dd-b862-8500afc1bf7e666' is not a valid Guid, that's easy to see: bytes are encoded as hexadecimal numbers, hence every byte takes up two characters. And now count the characters in each block: the last block has an odd number.
 
Share this answer
 
0f86759f-db8d-47dd-b862-8500afc1bf7e666 is an unconditional statement. Try different and valid GUID.
 
Share this answer
 
Comments
CHill60 22-Aug-22 8:07am    
You have essentially just said exactly the same thing that Bernhard Hiller said 10 years ago. Please take care that you are adding something new to a thread if you are going to revive it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900