• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

MAX ID problem

I have a numbering system i need to implement for a job databse.

When a user want a new job number they click the said Access 2000 front end button and the next number in sequence has to be given to them.

EG UK20006
      UK2007   number given would be UK2008

Having problems wrintg this as the cant increment as the type is varchar not int whats the work around

Using SQL server 2000.

I was asuming the button would fire a procedure.

Thanks in advance

MArk
0
ellandrd
Asked:
ellandrd
  • 2
1 Solution
 
Jay ToopsCommented:
This will do it unless you need to increment UK as well
also watch what happens when the id ROLLS OVER.


declare @currentid varchar (20)
declare @newid varchar(20)
set @currentid = 'UK2007'
set @newid = left(@currentid,2) + cast ( right(@currentid,4) + 1 as varchar(4) )
print @newid

Jay
0
 
ellandrdAuthor Commented:
How do i get

select MAX (JOBNO) FROM tbljobno

into

set @currentid = 'UK2007'


Thaks for the help


0
 
ellandrdAuthor Commented:
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now