Skip to main content

Create a Microsoft SQL Database table with 10,000 randomly generated numbers.

drop database if exists hello_world;
create database hello_world;
go

use [hello_world];
go

drop table if exists world;
create table world(id int identity(1, 1) not null,
    randomNumber int not null default 0,
    primary key(id)
);
go

declare @cnt int = 0;
declare @max int = 10000;

while @cnt < @max
    begin
        insert into world(randomNumber)
        values (ABS(CHECKSUM(NewId())) % 10000);
        set @cnt = @cnt + 1;
    end;
go

drop table if exists fortune;
create table fortune(
    id int identity(1, 1) not null,
    message nvarchar(2048) not null,
    primary key(id)
);
go

insert into fortune (message) values ('fortune: No such file or directory');
insert into fortune (message) values ('A computer scientist is someone who fixes things that aren''t broken.');
insert into fortune (message) values ('After enough decimal places, nobody gives a damn.');
insert into fortune (message) values ('A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
insert into fortune (message) values ('A computer program does what you tell it to do, not what you want it to do.');
insert into fortune (message) values ('Emacs is a nice operating system, but I prefer UNIX. --- Tom Christaensen');
insert into fortune (message) values ('Any program that runs right is obsolete.');
insert into fortune (message) values ('A list is only as strong as its weakest link. --- Donald Knuth');
insert into fortune (message) values ('Feature: A bug with seniority.');
insert into fortune (message) values ('Computers make very fast, very accurate mistakes.');
insert into fortune (message) values ('<script>alert("This should not be displayed in a browser alert box.");</script>');
insert into fortune (message) values ('フレームワークのベンチマーク');
go