Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
buzzi
Starting Member
48 Posts |
Posted - 2008-07-02 : 14:34:17
|
| Hi all,I was looking at the below post to see how to generate unique alpha numeric numbershttp://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-serverI was specifically looking at the below functioncreate function CustomerNumber(@i int) returns char(5) as begin return (char(@i / 26000 % 26 + 65) + char(@i / 1000 % 26 + 65) + char(@i / 100 % 10 + 48) + char(@i / 10 % 10 + 48) + char(@i % 10 + 48)) endI was able to figure out adding "65" the 1st 2 statements as these are base 26, the last 3 are base 10, but not able to figure out why "48" is added to the last 3??Thanks for any help |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-02 : 14:49:57
|
| It is used to get last three digit numbersSee what it returnsSelect char(48)So it is basically adding 0 to a number. Since char function is used, you need to use thatMadhivananFailing to plan is Planning to fail |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-07-02 : 14:50:14
|
| If you have questions about an article, you should post it in the article comments so that the author can answer.CODO ERGO SUM |
 |
|
|
|
|
|