Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Tworzenie hierarchii dla pierwszego urządzenia
- DECLARE @root HIERARCHYID;
- SET @root = HIERARCHYID::GetRoot();
- DECLARE @child HIERARCHYID;
- SET @child = @root.GetDescendant(NULL, NULL);
- -- Aktualizacja wartości w kolumnie device_hierarchy
- UPDATE Renewable_Energy_Devices
- SET device_hierarchy = @child
- WHERE device_id = 'Device_1';
- -- Aktualizacja wartości w kolumnie device_hierarchy dla wartości między 2 a 50
- DECLARE @j INT = 2;
- WHILE @j <= 50
- BEGIN
- SET @child = @child.GetDescendant(NULL, NULL);
- UPDATE Renewable_Energy_Devices
- SET device_hierarchy = @child
- WHERE device_id = 'Device_' + CAST(@j AS NVARCHAR(5));
- SET @j = @j + 1;
- END;
- -- Wyświetlenie zaktualizowanych rekordów
- SELECT * FROM Renewable_Energy_Devices;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement