Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Daily autoreset user-defined counter
Message
De
14/01/2001 10:13:08
 
 
À
14/01/2001 03:53:04
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
00463494
Message ID:
00463516
Vues:
13
Yes, you can use an insert trigger on the table that holds this field. Your trigger can either include the code below, or if the code below is a stored procedure, you trigger can call it.

Check in the BOL on triggers.

BOb


>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform