Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 incremental ID

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2004-08-04 : 12:49:03
How do I generate the incremental number that has both char and int.

The max ID from A table is AB1000 and I would like to generate the incremental number after the max ID. For example,

AB1000
AB1001
AB1002
.
.
.
.
.
AB50002




Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-08-04 : 12:55:44
store the # portion in a seperate field...
or if its always 2 characters at the beginning

Declare @myId varchar(10)

Set @myId = 'AB1031'

Select newId = left(@myId,2) + convert(varchar(10),convert(int,right(@myId,len(@myId)-2)) + 321)

Corey
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-08-04 : 13:34:33
You might want to look at

http://weblogs.sqlteam.com/brettk/archive/2004/06/29/1687.aspx



Brett

8-)
Go to Top of Page
   

- Advertisement -