sunny-j
asked on
unique number generator sql server
Greetings Experts,
I am looking to take something unique from this string below to add to a unique number, please can some tell me how to adjust so the result is two digits from the milliseconds numbers. thanks.
SUBSTRING(CONVERT(varchar( 12),GETDAT E(),113),9 ,13)
I am looking to take something unique from this string below to add to a unique number, please can some tell me how to adjust so the result is two digits from the milliseconds numbers. thanks.
SUBSTRING(CONVERT(varchar(
I am looking to take something unique from this string
The only thing which is unique in this string is the entire string. Cause each possible substring combination has collisions.
So the question is: What are you trying to do? Please post some information about your current context.
Especially as "adding a unique string" to another "unique string" makes no sense. Cause when one part is already unique, it's not relevant whether the other part is unique or not.
better use a GUID then - https://msdn.microsoft.com/en-us/library/ms187942.aspx?f=255&MSPPError=-2147217396
ASKER
I am sorry, I should have given more information from the start,
I want to create a password that has elements of the user's name along with something more unique. Its for a test system and later on we will allow them to create their own passwords. (adding say a 2-4 digit number to the end of password. thanks again.
UPDATE Table
SET [Password]=' SUBSTRING(LastName,2,3) + SUBSTRING(FirstName,1,3)+ SUBSTRING(CONVERT(nvarchar (24),getda te(), 113),23,24)
I want to create a password that has elements of the user's name along with something more unique. Its for a test system and later on we will allow them to create their own passwords. (adding say a 2-4 digit number to the end of password. thanks again.
UPDATE Table
SET [Password]=' SUBSTRING(LastName,2,3) + SUBSTRING(FirstName,1,3)+ SUBSTRING(CONVERT(nvarchar
easiest way to get the milliseconds is to use DatePart:
DATEPART(ms, GETDATE())
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all for your comments. Given Stefan's comment, I need to go back to the drawing board and decide how secure this needs to be at this stage. Kind regards.
Open in new window