Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
5 Character Generaton Routine
Message
 
 
To
25/08/2003 17:07:01
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00823200
Message ID:
00823229
Views:
28
Hi Terry,

You can use following code to convert integer value into Base36 encoded string.
DECLARE @i int, @key int, @Base36 char(36), @Key5 varchar(5)
SET @key = 1234578910
SET @Base36 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SET @Key5 = ''
SET @i = 1
WHILE @i < 6 
BEGIN
	SET @Key5 = SUBSTRING(@Base36, (@key % 36)+1,1) +  @Key5
	SET @key = CAST(@key / 36 AS int)
	SET @i = @i + 1
END
SELECT @Key5
>I am working with SQL Server 2000. I need to generate a unique 5 character code for use as a code that will be displayed to users on successful add of a new record.
>
>I am too new to SQL Stored Procedures to know where to start. I looked at the MD5 add in stored proc but it returns 32 characters. I must have only 5. I thought about taking the identity number and converting it to hex, but I dont know how.
>
>If some kind person out there would help me I would appreciate it.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform