Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
5 Character Generaton Routine
Message
 
 
À
25/08/2003 17:07:01
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00823200
Message ID:
00823229
Vues:
29
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform