Microsoft SQL Server 2008 R2 Unleashed- P165

Microsoft SQL Server 2008 R2 Unleashed- P165:SQL Server 2005 provided a number of significant new features and enhancements over what was available in SQL Server 2000. This is not too surprising considering there was a five-year gap between these major SQL Server 2008 is not as much of a quantum leap forward from SQL Server 2005 | 1584 CHAPTER 42 What s New for Transact-SQL in SQL Server 2008 with a slash sign used as a separator between the levels. For example you can run the following query to get both the binary and logical representations of the hid value select cast hid as varbinary 6 as hid substring 1 12 as path lvl partid partname From parts_hierarchy go hid path lvl partid partname 0x 0 22 Car 0x58 1 1 1 DriveTrain 0x68 2 1 23 Body 0x78 3 1 24 Frame 0x5AC0 1 1 2 2 Engine 0x5B40 1 2 2 3 Transmission 0x5BC0 1 3 2 4 Axle 0x5C20 1 4 2 12 Drive Shaft 0x5B56 1 2 1 3 9 Flywheel 0x5B5A 1 2 2 3 10 Clutch 0x5B5E 1 2 3 3 16 Gear Box 0x5AD6 1 1 1 3 5 Radiator 0x5ADA 1 1 2 3 6 Intake Manifold 0x5ADE 1 1 3 3 7 Exhaust Manifold 0x5AE1 1 1 4 3 8 Carburetor 0x5AE3 1 1 5 3 13 Piston 0x5AE5 1 1 6 3 14 Crankshaft 0x5AE358 1 1 5 1 4 21 Piston Rings 0x5AE158 1 1 4 1 4 11 Float Valve 0x5B5EB0 1 2 3 1 4 15 Reverse Gear 0x5B5ED0 1 2 3 2 4 17 First Gear 0x5B5EF0 1 2 3 3 4 18 Second Gear 0x5B5F08 1 2 3 4 4 19 Third Gear 0x5B5F18 1 2 3 5 4 20 Fourth Gear As stated previously the values stored in a Hierarchyid column provide topological sorting of the nodes in the hierarchy. The GetLevel method can be used to produce the level in the hierarchy as it was to store the level in the computed lvl column in the Parts_hierarchy table . Using the lvl column or the GetLevel method you can easily produce a graphical depiction of the hierarchy by simply sorting the rows by hid and generating indentation for each row based on the lvl column as shown in the following example Hierarchyid Data Type 1585 SELECT REPLICATEC--1 lvl right lvl partname AS partname FROM Parts_hierarchy order by hid go partname 42 Car -- DriveTrain ---- Engine . Radiator . Intake Manifold . Exhaust Manifold . Carburetor . Float Valve . Piston . Piston Rings . Crankshaft --- Transmission . Flywheel . Clutch . Gear Box . Reverse Gear . First Gear . Second Gear . Third Gear . Fourth Gear ---- Axle ---- Drive Shaft -- Body -- Frame To return

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.