Running a Contest with SQL Server

1 Comment

If you ever need to run a random drawing contest with a SQL Server database back end, here’s one way to do it:

Create a table to hold each person’s name and email address.  We use EntryID as a primary key, not their name or email, because a person can enter more than once.

Insert a record each time somebody enters:

Draw a random winner by running this script for each prize:

The “order by newid()” part will give us a random record out of the table.  The “where PrizeWon is null” part will make sure we don’t draw an entry again after it’s already won.

Previous Post
Top 10 SQL Server DBA Interview Questions
Next Post
PerformancePoint is very important to us, so…

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.