NewID()

I want to random select 5 records from my database… I got this code,

  Code:
 [LEFT]SELECT Top 5 * FROM comptbl ORDER BY NewID()[/LEFT]

but its gives me an error saying “[FONT=Arial][SIZE=2]Undefined function 'NewID() in expression.”
What must I do? The site is done in asp… with a access database - if that helps?..

thanks for the help! [/SIZE][/FONT]:puzzled:

Please don’t double post. Thanks.

I’ve never seen syntax like that in a SQL query…

NewId() only works on SQL server…

Try something like this:

<% 
    Randomize() 
    randNum = (CInt(1000 * Rnd) + 1) * -1 
 
    set conn = CreateObject("ADODB.Connection") 
 
    sql = "SELECT TOP 5 cols," & _ 
        "r = Rnd(" & randNum & ")" & _ 
        "FROM TableName " & _ 
        "ORDER BY r" 
 
    set rs = conn.execute(sql) 
 
    response.write rs(0) 
 
    ' ... 
    rs.close: set rs = nothing 
    conn.close: set conn = nothing 
%>