?
Solved

MAX ID problem

Posted on 2004-08-23
3
Medium Priority
?
205 Views
Last Modified: 2011-09-20
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
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
Jay Toops earned 2000 total points
ID: 11871526
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
 
LVL 16

Author Comment

by:ellandrd
ID: 11871828
How do i get

select MAX (JOBNO) FROM tbljobno

into

set @currentid = 'UK2007'


Thaks for the help


0
 
LVL 16

Author Comment

by:ellandrd
ID: 11871836
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question