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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
Try this:

SELECT SUBSTRING(CONVERT(nvarchar(24),getdate(), 113),23,24)

Open in new window

ste5anSenior DeveloperCommented:
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.
Éric MoreauSenior .Net ConsultantCommented:
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

sunny-jAuthor Commented:
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.

 SET [Password]=' SUBSTRING(LastName,2,3) + SUBSTRING(FirstName,1,3)+ SUBSTRING(CONVERT(nvarchar(24),getdate(), 113),23,24)
Éric MoreauSenior .Net ConsultantCommented:
easiest way to get the milliseconds is to use DatePart:

Open in new window

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
better attach random number (0-9999) at the end of your string as the password is already has unique characters taken from the first and last names.

SET [Password]=' SUBSTRING(LastName,2,3) + SUBSTRING(FirstName,1,3)+ (SELECT CAST(RAND() * 10000 AS INT) )

Open in new window

ste5anSenior DeveloperCommented:
First of all: Don't store passwords at all. This is a security issue. Store only a hash.

As it is about passwords: I don't see any sense to have easy to break passwords in a test environment.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunny-jAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.