May 6, 2005 at 7:17 am
I am devoloping a project for tourism company. They need to auto generate tourism file number in the following format: No/service month/service year, so when the user inputs the service date in the form the next file number is generated automatically calling the maximum number at that particular month and year and incrementing it by one. Any help?
May 9, 2005 at 8:00 am
This was removed by the editor as SPAM
May 9, 2005 at 12:41 pm
Until someone comes up with a better solution - create a stored procedure to format the next number and insert into table by passing the input service date:
1) Declare variable @tourismfilenumber varchar(50)
2) select top 1 row that matches the month and year of passed service date (you can do a datepart() function...) - order by tourismfilenumber DESC
3) Increment the number portion by doing something like this:
SELECT (LEFT(tourismfilenumber, PATINDEX('%/%', tourismfilenumber) - 1)) + 1
4) set variable @tourismfilenumber = concatenate new number + '/' + month + '/' + year
5) Insert new tourismfilenumber into your table
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply