create-sqlserver.sql 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. -- This SQL Server T-SQL script creates and populates the World and Fortune tables.
  2. --
  3. -- To run this script, make sure that you've already run create-sqlserver-login-and-database.sql
  4. -- to create the database user and database, then open a command prompt and run:
  5. --
  6. -- "%ProgramFiles%\Microsoft SQL Server\110\Tools\binn\sqlcmd.exe" -U benchmarkdbuser -P B3nchmarkDBPass -d hello_world -i <filename of this file>
  7. IF OBJECT_ID('World', 'U') IS NOT NULL
  8. DROP TABLE World
  9. GO
  10. CREATE TABLE World (
  11. id int NOT NULL IDENTITY PRIMARY KEY,
  12. randomNumber int NOT NULL default 0
  13. )
  14. GO
  15. -- Populate World table
  16. DECLARE @RowCount INT
  17. DECLARE @Random INT
  18. SET @RowCount = 0
  19. WHILE @RowCount < 10000
  20. BEGIN
  21. SELECT @Random = ((10000 + 1) - 1) * RAND() + 1
  22. INSERT INTO World (randomNumber) VALUES (@Random)
  23. SET @RowCount = @RowCount + 1
  24. END
  25. GO
  26. IF OBJECT_ID('Fortune', 'U') IS NOT NULL
  27. DROP TABLE Fortune
  28. GO
  29. -- Note that this uses nvarchar to make sure that the column is Unicode.
  30. CREATE TABLE Fortune (
  31. id int NOT NULL IDENTITY PRIMARY KEY,
  32. message nvarchar(2048) NOT NULL
  33. )
  34. GO
  35. INSERT INTO Fortune (message) VALUES (N'fortune: No such file or directory');
  36. INSERT INTO Fortune (message) VALUES (N'A computer scientist is someone who fixes things that aren''t broken.');
  37. INSERT INTO Fortune (message) VALUES (N'After enough decimal places, nobody gives a damn.');
  38. INSERT INTO Fortune (message) VALUES (N'A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
  39. INSERT INTO Fortune (message) VALUES (N'A computer program does what you tell it to do, not what you want it to do.');
  40. INSERT INTO Fortune (message) VALUES (N'Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
  41. INSERT INTO Fortune (message) VALUES (N'Any program that runs right is obsolete.');
  42. INSERT INTO Fortune (message) VALUES (N'A list is only as strong as its weakest link. — Donald Knuth');
  43. INSERT INTO Fortune (message) VALUES (N'Feature: A bug with seniority.');
  44. INSERT INTO Fortune (message) VALUES (N'Computers make very fast, very accurate mistakes.');
  45. INSERT INTO Fortune (message) VALUES (N'<script>alert("This should not be displayed in a browser alert box.");</script>');
  46. INSERT INTO Fortune (message) VALUES (N'フレームワークのベンチマーク');
  47. GO