sql server - Avoid generating duplicating random number -
that requires the first 4 four modules per file to be in the form of the name length, as 8 characters Trying to get a random number from the database using the . My question: Each line will be included in the fileNamerandomNUM for example: dba.GenerateRandomNumbersLetters (4) For this, it will provide a random number, but in a scenario randomly generated duplicate, how can I survive from such scenarios, please advice Repeat the value for a random number There is a danger, especially if you take only the first four digits of the random number. Instead, generate sequence numbers. To apply it, you can create a table with the structure Then every time you want to get a file name, the query against this table for the next serial number DDMM and the remaining four characters function and the view, similarly I am using the database I have pasted below: < P> Function:
create function [dbo] [GenerateRandomNumbersLetters] (@NumberOfCharacters TINYINT) Return as VARCHAR (32) (left (REPLACE ([NewID], '-', ''), @NumberOfCharacters) from dbo. Retrieve Newweed; End: See
See [dbo] Create [RetrieveNewID] as selection [NewID] = NEWID ();
is selected in place of SUBSTRING (changed (varchar (10), getdate (), 3), '/', ' For example:
0907CCE7
file_date | Seek_Ax0907 | 1000 0907 | 1001
select max (seq_no ) With your +1 & LT; Table & gt;
Comments
Post a Comment