Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6641393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:48:20+00:00 2026-05-25T23:48:20+00:00

I am using SQL Server 2008. A while back, I asked the question should

  • 0

I am using SQL Server 2008.

A while back, I asked the question “should I use RecordID in a junction table”. The tables would look like this:

// Images
ImageID// PK

// Persons
PersonID // pk

// Images_Persons
RecordID // pk
ImageID // fk
PersonID // fk

I was strongly advised NOT to use RecordID because it’s useless in a table where the two IDs create a unique combination, meaning there will be no duplicate records.

Now, I am trying to find a random record in the junction table to create a quiz. I want to pull the first id and see if someone can match the second id. Specifically, I grab a random image and display it with three possible choices of persons.

The following query works, but I’ve quite a bit of negativity that suggests that it’s very slow. My database might have 10,000 records, so I don’t think that matters much. I’ve also read that the values generated aren’t truly random.

SELECT TOP 1 * FROM Images_Persons ORDER BY newid();

Should I add the RecordID column or not? Is there a better way to find a random record in this case?

Previous questions for reference

  • Should I use "RecordID" as a column name?
  • SQL – What is the best table design to store people as musicians and artists?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:48:21+00:00Added an answer on May 25, 2026 at 11:48 pm

    Consider what you’ve got.

    SELECT TOP 1 * FROM Images_Persons ORDER BY newid();
    

    Not truly random? Excluding the ‘truly random is impossible’ bit, you’re probably right – I believe that there are patterns in generated uniqueidentifiers. But you should test this yourself. It’d be simple; just create a table with 1 to 100 in it, order by newid() a lot of times, and look at the results. If it’s random ‘enough’ for you (which it probably will be, for a quiz) then it’s good enough.

    Very slow? I wouldn’t worry about that. I’d be very surprised if the newid() is slower than reading the record from the table. But again, test and benchmark.

    I’d be happy with the solution you have, pending tests if you’re concerned about it.

    I’ve always used order by newid().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQL Server 2008 and I would like to use a sproc to
using sql server 2008 I would like to take a table that has 11
Using SQL Server 2008, is there a way to allow inserts to a table
I am using SQL Server 2008. I have a table A which accepts many
I am using SQL Server 2008, and I have two tables Table1 contains 3.5
We are using SQL Server 2008. We have a table called response which has
I'm using SQL Server 2008 R2. I have a source table of data (I_Vendor)
I am using Microsoft SQL Server 2008. While generating custom reports, I need to
I'm using SQL Server 2008. I should be able to connect to a user-specified
This is a question for a SQL specialist! I'm using SQL SERVER 2008 R2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.