sql-server - 如何在 sql server 中对 guid 进行 base64 编码

标签 sql-server base64 guid

如何在 sql server 2005 中使用 uniqueidentifier 数据类型重新创建以下 c# 代码。

string encoded = Convert.ToBase64String(guid.ToByteArray());

我尝试了几个我在互联网上遇到的例子,例如 http://www.vbforums.com/showthread.php?t=554886但它们都返回比 .net 函数长得多的字符串。

最佳答案

如果您传入唯一标识符,您链接中的示例将起作用

Guid guid = Guid.NewGuid();
string encoded = Convert.ToBase64String(guid.ToByteArray());
Console.WriteLine(guid);
Console.WriteLine(encoded);

对于

32705fe3-cedd-4bfd-a881-9dd11e543f9e
419wMt3O/UuogZ3RHlQ/ng==

declare @guid uniqueidentifier = '32705fe3-cedd-4bfd-a881-9dd11e543f9e'
select dbo.f_BinaryToBase64(@guid)

对于

419wMt3O/UuogZ3RHlQ/ng==

关于sql-server - 如何在 sql server 中对 guid 进行 base64 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9178233/

相关文章:

sql - 内连接查询的区别

file - 钛从流中保存文件

python - 何时为 COM 服务器生成新的 GUID? (Python 中的示例)

database-design - 数据库设计问题: Treating GUID's around the place

SQL Server 外键约束问题

sql-server - 从 Powershell 调用的存储过程不通过 SMO 对象执行

c++ - 计算 Base64 编码消息的大小

PHP 验证 base64 编码的图像

c#-4.0 - 限制 GUID 中的字符数

sql-server - 可串行化事务死锁