Wow, that's purrfect!

Tim Cadieux
(613) 947-4895
Technical Applications Analyst / Analyste des applications techniques 
Client Services Section / Section de services � la client�le 
Administrative Services Division / Division des services administratifs
Corporate Services Branch / Direction des services minist�riels
Facsimile / T�l�copieur : (613) 947-8799
 


 -----Original Message-----
From:   Andrew Zetterman [mailto:[EMAIL PROTECTED]] 
Sent:   September 25, 2002 6:35 PM
To:     ActiveServerPages
Subject:        RE: Random picture from a Database

SQL Books Online
-----------------------------

NEWID
Creates a unique value of type uniqueidentifier. 

Syntax
NEWID ( ) 

Return Types
uniqueidentifier
-----------------------------

So if you put it into your order by it will generate a unique id for
each record and then it will sort by that column.  Each time you query
the unique id will be different so the order of your records will
change.  So the top 1 record will randomly change.

Andrew

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, September 25, 2002 2:36 PM
To: ActiveServerPages
Subject: RE: Random picture from a Database



How exactly does the below code work?, I haven't seen that before.

 -----Original Message-----
From:   Andrew Zetterman [mailto:[EMAIL PROTECTED]] 
Sent:   September 25, 2002 9:42 AM
To:     ActiveServerPages
Subject:        RE: Random picture from a Database

David Penton posted a query a few weeks ago that could select a random
record.

SELECT TOP 1 col FROM tbl ORDER BY NEWID()

HTH,

Andrew



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, September 25, 2002 8:29 AM
To: ActiveServerPages
Subject: RE: Random picture from a Database


But how do I get a random pic from the remaining pics?

 -----Original Message-----
From:   Matthew Small [mailto:[EMAIL PROTECTED]] 
Sent:   September 25, 2002 9:19 AM
To:     ActiveServerPages
Subject:        RE: Random picture from a Database

Put a binary field in your table.  If the field is set, don't use that
picture.

Matthew Small
IT Supervisor
Showstopper National Dance Competitions
3660 Old Kings Hwy
Murrells Inlet, SC 29576
843-357-1847
http://www.showstopperonline.com
 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, September 25, 2002 9:14 AM
To: ActiveServerPages
Subject: Random picture from a Database

I just want to show a random picture form all those in my database.  I
used to just get the number of pics in my DB, then geta RND # and then
call that ID, but, because I Autonumber them, when a pic got deleted, I
would sometimes get an error.

So, how can I get a rnd Pic ID from a database that has say 20 pics, but
10 are set to NOT be shown....ideas?

Tim


---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED] To unsubscribe send a blank email to
%%email.unsub%%




---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED] To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED] To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED] To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED] To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to