create-sqlserver.sql 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. -- TODO: Check for an existing World table and drop it.
  8. CREATE TABLE World (
  9. id int NOT NULL IDENTITY PRIMARY KEY,
  10. randomNumber int NOT NULL default 0
  11. )
  12. GO
  13. -- Populate World table
  14. DECLARE @RowCount INT
  15. DECLARE @Random INT
  16. SET @RowCount = 0
  17. WHILE @RowCount < 10000
  18. BEGIN
  19. SELECT @Random = ((10000 + 1) - 1) * RAND() + 1
  20. INSERT INTO World (randomNumber) VALUES (@Random)
  21. SET @RowCount = @RowCount + 1
  22. END
  23. GO
  24. -- TODO: Check for an existing Fortune table and drop it.
  25. -- Note that this uses nvarchar to make sure that the column is Unicode.
  26. CREATE TABLE Fortune (
  27. id int NOT NULL IDENTITY PRIMARY KEY,
  28. message nvarchar(2048) NOT NULL
  29. )
  30. GO
  31. INSERT INTO Fortune (message) VALUES ('fortune: No such file or directory');
  32. INSERT INTO Fortune (message) VALUES ('A computer scientist is someone who fixes things that aren''t broken.');
  33. INSERT INTO Fortune (message) VALUES ('After enough decimal places, nobody gives a damn.');
  34. INSERT INTO Fortune (message) VALUES ('A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
  35. INSERT INTO Fortune (message) VALUES ('A computer program does what you tell it to do, not what you want it to do.');
  36. INSERT INTO Fortune (message) VALUES ('Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
  37. INSERT INTO Fortune (message) VALUES ('Any program that runs right is obsolete.');
  38. INSERT INTO Fortune (message) VALUES ('A list is only as strong as its weakest link. — Donald Knuth');
  39. INSERT INTO Fortune (message) VALUES ('Feature: A bug with seniority.');
  40. INSERT INTO Fortune (message) VALUES ('Computers make very fast, very accurate mistakes.');
  41. INSERT INTO Fortune (message) VALUES ('<script>alert("This should not be displayed in a browser alert box.");</script>');
  42. INSERT INTO Fortune (message) VALUES ('フレームワークのベンチマーク');
  43. GO