Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Daily autoreset user-defined counter
Message
From
14/01/2001 10:13:08
 
 
To
14/01/2001 03:53:04
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
00463494
Message ID:
00463516
Views:
12
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform