Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sys(3)

Status
Not open for further replies.

RichardH

Programmer
Apr 21, 2001
46
0
0
US
Can anyone tell me more about sys(3). I know it generates a randum number, but what is it based on. Will it always be unique over time and on different computers.

I want to be able to generate randum numbers on different computers and be sure that they are all unique.

Thanks
 
See thread184-754618 Randomly Generating Numbers

Brian
 
RichardH,
First SYS(3), doesn't generate a "random" number, but rather unique numbers for the given system. (They are based on the system time and the previously generated values!)

The only way to generate truely unique "numbers" across multiple systems is to either use a unique ID for each system (e.g. MAC address) concatenated to SYS(3), or use the Microsoft GUID. There are two FAQs that can help you there - faq184-230 and faq184-2486.

Rick
 
Thanks for the help. It appears that the Microsoft GUID is exactly what I need.
 
Richard,

Usually, the RAND() function will give a random number which serves most purposes. A GUID isn't a random number, strictly speaking, but a rather a globally unique number. Whether that will work for you or not depends on what you want to use it for.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
GUID seems to be what I need. I have users at headquarters and also users running around with laptops. They will all be entering data which will be combined into one data table at HQ and I need a unique id# for each record.
 
Richard,

In that case, you are right -- GUID is what you need. Just be aware that it generates a very long string. Efficiency-wise, the string is very long for a primary key.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top