Sometimes there is a situation in which we need to generate a unique random number with some prefix. For example, in Railway, reservation a number like RAIL4562 .
When you run above-stated query, the result will look like below:
Credit for this Logic : Vinay
There are various approaches to achieve this . But, we can do this using following query.
select 'LearnAll'+cast((SELECT 10 + CONVERT(INT, ((9999-10)+1)*RAND())) as varchar)
When you run above-stated query, the result will look like below:
LearnAll1382
LearnAll8342
Credit for this Logic : Vinay
For More Updates stay connected On : Learn2All Facebook Page
Amazing Concepts in Video : Video On YouTube
Comments
Post a Comment