convert guid to varchar in sql server code example Example: convert sql server guid to varbinary select cast(hashbytes('md5','foo') as uniqueidentifier)