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 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 ();   

My question:

  is selected in place of SUBSTRING (changed (varchar (10), getdate (), 3), '/', ' For example:  0907CCE7   

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

Post-text "itemprop =" text ">

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

  file_date | Seek_Ax0907 | 1000 0907 | 1001   

Then every time you want to get a file name, the query against this table for the next serial number

  select max (seq_no ) With your +1 & LT; Table & gt;    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -