Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need string function help
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Need string function help
Divers
Thread ID:
00475503
Message ID:
00475503
Vues:
80
I am attempting to create a trigger which will assign a policy number to a record, and am having some trouble with the string function.

I have a field called 'lastused', which is a counter. Every time a record is added to the system, 'lastused' is incremented by 1.

The policy number format is "XXX" + several zeros + the stringed and trimmed value of 'lastused'. It is a 12 character field. For instance, if 'lastused' = 123, then the policy number should be "XXX000000123". If 'lastused' is 1234567, the the policy number should be "XXX001234567". But I am having a devil of a time getting the right number of '0' inserted between the "XXX" and the lastused number.

Current code is:

policynumber = "XXX" + stuff(str(lastused,4,(9 - len(lastused))), '0')

This gives me "XXX0 1234"

It is probably simple, but.....

Marie
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform