SHARE
TWEET

Untitled

a guest Aug 25th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. USE Countries
  2.  
  3. IF OBJECT_ID('dbo.CityTemperatureSource') is not null
  4. BEGIN
  5.     DROP TABLE dbo.CityTemperatureSource
  6. END
  7.  
  8. SELECT *
  9. INTO dbo.CityTemperatureSource
  10. FROM dbo.CityTemperature
  11.  
  12. IF OBJECT_ID('dbo.CityTemperatureDestination') is not null
  13. BEGIN
  14.     DROP TABLE dbo.CityTemperatureDestination
  15. END
  16.  
  17.  
  18. SELECT *
  19. INTO dbo.CityTemperatureDestination
  20. FROM dbo.CityTemperature
  21.  
  22. UPDATE dbo.CityTemperatureSource
  23. SET AverageTemperature = AverageTemperature + 1
  24. WHERE AverageTemperature between 2 and 5 and
  25. Occurence not in
  26. (  
  27.     '1833-03-01',
  28.     '1833-04-01',
  29.     '1833-05-01',
  30.     '1833-06-01',
  31.     '1833-07-01',
  32.     '1833-08-01',
  33.     '1833-09-01',
  34.     '1833-10-01',
  35.     '1833-11-01'
  36. )
  37. --(418703 rows affected)
  38.  
  39. DELETE FROM dbo.CityTemperatureSource
  40. WHERE Occurence in
  41. (
  42.     '1833-03-01',
  43.     '1833-04-01',
  44.     '1833-05-01',
  45.     '1833-06-01',
  46.     '1833-07-01',
  47.     '1833-08-01',
  48.     '1833-09-01',
  49.     '1833-10-01',
  50.     '1833-11-01'
  51. )
  52. --(21042 rows affected)
  53.  
  54. DECLARE @i int = 100000000
  55. WHILE @i < 100200000
  56. BEGIN
  57.     INSERT INTO dbo.CityTemperatureSource
  58.         (
  59.             [Id],
  60.             [Occurence],
  61.             [AverageTemperature],
  62.             [AverageTemperatureUncertainty],
  63.             [CityName],
  64.             [CountryName],
  65.             [Latitude],
  66.             [Longitude]
  67.         )
  68.     VALUES (@i, '2020-01-01', 12, 2.5, 'CityName', 'CountryName', '1.1N', '1.1E')
  69.    
  70.     SET @i = @i + 1
  71. END
  72. --(200000 rows affected)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top