![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 5 of 5 total |
![]() |
Fri, Jun 6 2008 2:32 PM | Permanent Link |
John | The Manual says about the SQL RAND function:
"The RAND function returns a random number" I need do create a random password with a fixed length of 6 characters. Is that possible with SQL using the RAND function? |
Fri, Jun 6 2008 3:06 PM | Permanent Link |
Roy Lambert NLH Associates ![]() | John
Your problem is that RAND(999999) could return anything from 0 to 999999 which would not be useful for your purposes. If you're running V4 you'd be better off writing your own function and calling that. Otherwise you could do something like CAST(RAND(9) AS VARCHAR(1)) + CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1)) or SUBSTR(TRIM(CAST(RAND(999999) AS VARCHAR(6)) + TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) ,1,6) Roy Lambert |
Fri, Jun 6 2008 3:51 PM | Permanent Link |
"Robert" | "John" <eydunl@post.olivant.fo> wrote in message news:0412E3AE-689B-4CA6-9147-BF99848FF77F@news.elevatesoft.com... > The Manual says about the SQL RAND function: > "The RAND function returns a random number" > > I need do create a random password with a fixed length of 6 characters. > Is that possible > with SQL using the RAND function? > Are spaces allowed? Robert |
Fri, Jun 6 2008 5:17 PM | Permanent Link |
John | No Spaces are not allowed. Only numbers.
Roy, thanks for the reply ![]() |
Mon, Jun 9 2008 5:08 AM | Permanent Link |
"John Hay" | Roy
> CAST(RAND(9) AS VARCHAR(1)) + CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1))+CAST(RAND(9) AS VARCHAR(1)) > > or > > SUBSTR(TRIM(CAST(RAND(999999) AS VARCHAR(6)) + TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) +TRIM(CAST(RAND(999999) AS VARCHAR(6)) ,1,6) How about RAND(899999)+100000 <bg> John |
This web page was last updated on Wednesday, July 2, 2025 at 06:46 PM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |