Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Daily autoreset user-defined counter
Message
De
14/01/2001 03:53:04
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Daily autoreset user-defined counter
Divers
Thread ID:
00463494
Message ID:
00463494
Vues:
46
Hi readers!

I have a column (Box Serial Number) with the next format:
YYDDDSSSSS where:
YY - last two digits of year
DDD - Day of year ( 001 - 365)
SSSSS - Consecutive number.

I need a user-defined counter that everyday begins at 1 but changes every time I insert a row in a table. I am new mssql7 user (2 days old) so I think I must use a trigger (insert) to achieve this but I do not how to reset this counter.

Here is my code that build the serial number, but I don´t know how to call any of the ten user-defined counter availables.

Set dateformat dmy
DECLARE @BSN CHAR(12)
SET @BSN =
substring(convert(char,getdate(),121),3,2)+substring(str(datediff(day,convert(datetime,'31/12/'+str(year(getdate())-1,4)),getdate())+1000,4),2,3)+SSSSSS

any kind of suggestion is wellcome

thanks in advance!
Martin Alcaraz
malacaraz@rtn.uson.mx
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform