Results 1 to 2 of 2

Thread: Random Values

  1. #1
    Join Date
    Nov 2003
    Location
    Israel
    Posts
    41

    Unanswered: Random Values

    I have a table with 3 fields SiteID (PK), SiteCode, SiteName.
    For each SiteCode I have several rows with different SiteName.
    For example: 1 327 a
    2 327 b
    3 327 c
    4 328 aa
    5 328 bb......

    I need to retrieve each time SiteCode with random SiteName.
    For example: 327 b , 327 a , 327 c
    328 aa 328 bb 328 aa.

    I need it very urgent, so any ideas will be very helpful. Thanks to all,

  2. #2
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    74

    Just a hint ....

    Ok, I admit that I haven't had time to test this, and what I suggest isn't a complete solution, but here goes anyway ...

    In SQL-server you can use the Rand() - function. The only problem with that function is that it needs a seed to generate diffirent output each time it's called, so what I did to fix a "dirty-semi-random"-thingy was that I hooked up the datepart-function with the Rand()-function to get you started as in

    select rand(datepart(ms, getdate()))

    perhaps the above line could generate a "random-enough" number to base your upcoming task on, i.e using the number (or part of the number) as a decisionbase about what row to select?
    The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •