SQL: 将int型转换为UNIQUEIDENTIFIER
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL: 将int型转换为UNIQUEIDENTIFIER相关的知识,希望对你有一定的参考价值。
DECLARE
@I
INT
SELECT
@I=123456
SELECT
CAST
(
CAST
(@I
AS
varbinary(16))
AS
UNIQUEIDENTIFIER)
SELECT
CAST
(
CAST
(@I
AS
binary
(16))
AS
UNIQUEIDENTIFIER)
SELECT
CAST
(
CAST
(@I
AS
binary
(4))+
CAST
(@I
AS
binary
(4))+
CAST
(@I
AS
binary
(4))+
CAST
(@I
AS
binary
(4))
AS
UNIQUEIDENTIFIER)
SELECT
CAST
(
CAST
(REPLICATE(
CAST
(@I
AS
binary
(4)),4)
AS
binary
(16))
AS
UNIQUEIDENTIFIER)
SELECT
CAST
(
CAST
(HASHBYTES(
‘MD5‘
,
CAST
(@I
AS
varbinary(4)))
AS
binary
(16))
AS
UNIQUEIDENTIFIER)
SELECT
CAST
(
CAST
(HASHBYTES(
‘MD5‘
,
CAST
(@I
AS
varchar
(20)))
AS
binary
(16))
AS
UNIQUEIDENTIFIER)
以上是关于SQL: 将int型转换为UNIQUEIDENTIFIER的主要内容,如果未能解决你的问题,请参考以下文章
我的SQL 运行提示 DBA数据层_错误将 expression 转换为数据类型 int 时发生算术溢出错误
如何将Sql中的money类型的数据转化为C#中的int型?