DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to generate roulette wheel random numbers?

Execute the following Microsoft SQL Server T-SQL script in Management Studio Query Editor to generate random numbers in the range of 00, 0, 1-36 for American roulette wheel simulation. European (Monte Carlo) roulette wheel does not have 00.

-- Monte Carlo Simulation

-- SQL Server T-SQL random number generation with range of 38 integers

-- T-SQL newid, rand, round, cast, replace, char functions - MSSQL while loop

USE AdventureWorks;

 

DECLARE  @i INT

 

SET @i = 0

 

WHILE (@i < 100)

  BEGIN

    SELECT Replace(Cast(Round(Rand(Cast(Newid() AS VARBINARY)) * 38,0,-1) AS CHAR(2)),

                   '37','00')

    

    SET @i = @i + 1

  END

 

GO

/* Partial results

13

14

21

34

4

7

00

16

8

*/

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE