Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Increment a number within a string
Message
 
 
À
04/12/2007 14:03:50
Greg Rowe
Memphis Police Department
Memphis, Tennessie, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01273115
Message ID:
01273116
Vues:
16
>I need to imcrement a number within a string such as ME20070019. I need the ME to remain as a constant. The 2007 is the current year. I need to be able to increment the 0019 by one for each time the record is written to the file.
DECLARE @strkey varchar(50), @strkeynext varchar(50)
SET @strkey = 'ME20070019'
SET @strkeynext = LEFT(@strkey,6) + RIGHT( '0000' + CAST(SUBSTRING(@strkey,7,4) + 1 AS varchar(10)), 4) 
SELECT @strkeynext
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform