Post Reply 
(32S) SQL Server Size Converter
05-16-2015, 10:59 PM
Post: #1
(32S) SQL Server Size Converter
In case there are any other SQL Server DBAs here...

SQL Server stores data in "pages", which are simply 8 KB allocation units within a data file, and the smallest unit of measure by which SQL Server allocates storage space. Object sizes are frequently reported in pages, rather than bytes.

Disk I/O is performed in a minimum unit of storage called an "extent", which is simply a 64 KB block of 8 pages.

Here's a program to quickly convert between pages, extents, KB, MB, and GB.

This is based on the cyclical style of unit converters presented in the 32S manual. So XEQ D to start the program, and either enter the number of pages at the "P?" prompt, or press R/S until the unit you wish to enter is displayed.

After selecting the appropriate unit and entering the input value, press R/S to cycle through the units until the desired output unit is displayed.

Example: Convert 256 MB to pages.
Code:
Input    Display
XEQ D    P?0
R/S    E?0
R/S    K?0
R/S    M?0
256    M? 256_
R/S    G?0.25
R/S    P?32,768

Answer: 32,768 pages.

Note that the program temporarily sets FIX 4 to round the number of pages to prevent small errors when converting from GB back to pages. You can either delete lines D02 through D04 if you wish to eliminate this behavior, or change the ALL instruction in line D04 to switch back to your display mode of choice.

Program listing:

Code:
D01 LBL D - 46.5 bytes, 80BA
D02 FIX 4
D03 RND (entered as PARTS, RN)
D04 ALL
D05 STO P
D06 INPUT P
D07 8
D08 /
D09 STO E
D10 INPUT E
D11 64
D12 *
D13 STO K
D14 INPUT K
D15 2
D16 10
D17 y^x
D18 /
D19 STO M
D20 INPUT M
D21 2
D22 10
D23 y^x
D24 /
D25 STO G
D26 INPUT G
D27 2
D28 17
D29 y^x
D30 *
D31 GTO D
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)