From varchar(36) to UNIQUEIDENTIFIER

Posted by jgonchik on Stack Overflow See other posts from Stack Overflow or by jgonchik
Published on 2010-04-23T12:42:36Z Indexed on 2010/04/23 12:53 UTC
Read the original article Hit count: 501

I am trying to cast an AuctionId that is a UNIQUEIDENTIFIER to an varchar(36) and then back to an UNIQUEIDENTIFIER. Please help me.

CAST((SUBSTRING(CAST([AuctionId] as VARCHAR(36)), 0, 35) + '1') AS UNIQUEIDENTIFIER)

But I keep getting this error:

Msg 8169, Level 16, State 2, Line 647 Conversion failed when converting from a character string to uniqueidentifier.

Thanks in advance

© Stack Overflow or respective owner

Related posts about sql

Related posts about cast