Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Tworzenie zmiennych dla współrzędnych geograficznych i geometrycznych
- DECLARE @latitude DECIMAL(9, 6), @longitude DECIMAL(9, 6);
- DECLARE @point GEOMETRY;
- DECLARE @hierarchy HIERARCHYID;
- DECLARE @device_description XML;
- -- Pętla wypełniająca tabelę
- DECLARE @i INT = 1;
- WHILE @i <= 50
- BEGIN
- -- Generowanie losowych danych dla każdej kolumny
- SET @latitude = RAND() * 180 - 90;
- SET @longitude = RAND() * 360 - 180;
- SET @point = GEOMETRY::Point(@latitude, @longitude, 4326);
- SET @hierarchy = HIERARCHYID::GetRoot();
- SET @device_description = '<description>Device ' + CAST(@i AS NVARCHAR(5)) + '</description>';
- -- Wstawianie danych do tabeli
- INSERT INTO Renewable_Energy_Devices (device_id, device_status, device_power, company_id, device_location, device_location_geom, device_hierarchy, device_description)
- VALUES (
- 'Device_' + CAST(@i AS NVARCHAR(5)), -- device_id
- CAST(RAND() * 6 AS INT), -- device_status
- CAST(RAND() * 1000 AS DECIMAL(18, 0)), -- device_power
- CAST(RAND() * 10 AS INT) + 1, -- company_id
- GEOGRAPHY::Point(@latitude, @longitude, 4326), -- device_location
- @point, -- device_location_geom
- @hierarchy.GetDescendant(NULL, NULL), -- device_hierarchy
- @device_description -- device_description
- );
- SET @i = @i + 1;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement