Advertisement

06.30.2008 at 09:27AM PDT, ID: 23527459
[x]
Attachment Details

Random order by

Asked by gogetsome in SQL Server 2005

Tags: sql 2005

Hello, I'm trying to use the folllowing to order my select statement randomly, but get the following error:
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near 'LIMIT'.

I've seen a bunch of examples and can't seem to get any of them tho work.
What is the best way to have my select statement return the rows in a random order?

SELECT
      a.[slideid],
      a.[albumid],
      a.[title],
      a.[description],
      a.[image],
      a.[thumbnail]
      FROM LandT_Slide a, LandT_Album b
      WHERE b.albumtype = @albumtype
      and a.albumid = b.albumid
      ORDER BY RAND() LIMIT 1
Start Free Trial
[+][-]06.30.2008 at 09:28AM PDT, ID: 21900593

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 09:29AM PDT, ID: 21900611

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: sql 2005
Sign Up Now!
Solution Provided By: chapmandew
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628