博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Replication--将LSN转换成16进制
阅读量:6941 次
发布时间:2019-06-27

本文共 1095 字,大约阅读时间需要 3 分钟。

在复制中经常会使用到16进制的LSN,但在日志fn_dblog中的LSN是数字形式,于是从网上找到以下转换函数

CREATE FUNCTION dbo.fn_convertnumericlsntobinary(
@numericlsn numeric(25,0)
) returns binary(10)
AS
BEGIN
-- Declare components to be one step larger than the intended type
-- to avoid sign overflow problems. For example, convert(smallint, convert(numeric(25,0),65535)) will fail but convert(binary(2),
-- convert(int,convert(numeric(25,0),65535))) will give the
-- intended result of 0xffff.
declare @high4bytelsncomponent bigint,
@mid4bytelsncomponent bigint,
@low2bytelsncomponent int
select @high4bytelsncomponent = convert(bigint, floor(@numericlsn / 1000000000000000))
select @numericlsn = @numericlsn - convert(numeric(25,0), @high4bytelsncomponent) * 1000000000000000
select @mid4bytelsncomponent = convert(bigint,floor(@numericlsn / 100000))
select @numericlsn = @numericlsn - convert(numeric(25,0), @mid4bytelsncomponent) * 100000
select @low2bytelsncomponent = convert(int, @numericlsn)
return convert(binary(4), @high4bytelsncomponent) +
convert(binary(4), @mid4bytelsncomponent) +
convert(binary(2), @low2bytelsncomponent)
END

转载地址:http://wwinl.baihongyu.com/

你可能感兴趣的文章
Instana发布微服务应用程序样例
查看>>
京东Vue组件库NutUI 2.0发布:将支持跨平台!
查看>>
新书问答:Agile Management
查看>>
Apache HBase的现状和发展
查看>>
LinkedIn工程经理眼中的数据世界格局
查看>>
Servlet续篇
查看>>
AWS开源Firecracker,一种运行多租户容器服务的新虚拟化技术
查看>>
PHP扩展库PEAR被攻击,近半年下载者或被影响
查看>>
企业微信自建应用开发初探
查看>>
O’Reilly发布“微服务成熟度状态”报告:微服务是成功的
查看>>
Submarine:在 Apache Hadoop 中运行深度学习框架
查看>>
《Clojure Recipes》书评与问答
查看>>
腾讯集团与光大集团签署战略合作 共建金融科技创新实验室
查看>>
怀疑在软件测试中所起的作用
查看>>
5G一周热闻:华为夺联通5G大单,首张5G电话卡发放
查看>>
2018年Github最受欢迎机器学习语言Python稳坐冠军,numpy、scipy是最受欢迎软件包...
查看>>
GitHub 重磅更新:无限私有仓库免费使用
查看>>
“10%时间”:优点和缺点——敏捷海滩会议上Elizabeth Pope的报告
查看>>
Rico Mariani对Visual Studio不是64位的解释
查看>>
破译密码、设计飞机和建设团队:Randy Shoup谈高绩效团队
查看>>