-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from amtwo/v21.0
V21.0
- Loading branch information
Showing
18 changed files
with
342 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'IF' AND object_id = object_id('dbo.Convert_LSNFromHexToDecimal')) | ||
EXEC ('CREATE FUNCTION dbo.Convert_LSNFromHexToDecimal() RETURNS TABLE AS RETURN SELECT Result = ''This is a stub'';' ) | ||
GO | ||
|
||
|
||
ALTER FUNCTION dbo.Convert_LSNFromHexToDecimal (@LSN varchar(22)) | ||
RETURNS TABLE | ||
/************************************************************************************************* | ||
AUTHOR: Andy Mallon | ||
CREATED: 20190401 | ||
LSN is sometimes represented in hex (ie, from DBCC PAGE, fn_dblog(), sys.dm_db_page_info) | ||
Hex LSNs are represented in the format '0000001e:00000038:0001' | ||
Decimal LSNs are in the format 30000000005600001 | ||
PARAMETERS: | ||
@LSN - Text string of the hex version of the LSN | ||
In the format '0000001e:00000038:0001' | ||
EXAMPLES: | ||
* SELECT * FROM dbo.Convert_LSNFromHexToDecimal(0000001e:00000038:0001') | ||
************************************************************************************************** | ||
MODIFICATIONS: | ||
20190401 - | ||
************************************************************************************************** | ||
This code is licensed as part of Andy Mallon's DBA Database. | ||
https://github.com/amtwo/dba-database/blob/master/LICENSE | ||
©2014-2020 ● Andy Mallon ● am2.co | ||
*************************************************************************************************/ | ||
|
||
-- Split LSN into segments at colon | ||
-- Convert to binary style 1 -> int | ||
-- Add padded 0's to 2nd and 3rd string | ||
-- Concatenate those strings & convert back to int | ||
|
||
RETURN | ||
--First chunk | ||
SELECT LSN = CONVERT(decimal(25), | ||
CONVERT(varchar(10), | ||
CONVERT(int, | ||
CONVERT(varbinary, '0x' + RIGHT(REPLICATE('0', 8) + LEFT(@LSN, 8), 8), 1) | ||
) | ||
) | ||
--Second chunk | ||
+ RIGHT(REPLICATE('0', 10) + CONVERT(varchar(10), | ||
CONVERT(int, | ||
CONVERT(varbinary, '0x' + RIGHT(REPLICATE('0', 8) + SUBSTRING(@LSN, 10, 8), 8), 1) | ||
) | ||
), | ||
10) | ||
--Third chunk | ||
+ RIGHT(REPLICATE('0', 5) + CONVERT(varchar(5), | ||
CONVERT(int, | ||
CONVERT(varbinary, '0x' + RIGHT(REPLICATE('0', 8) + RIGHT(@LSN, 4), 8), 1) | ||
) | ||
), | ||
5) | ||
); | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.