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)
 A table with auto increment charter ID field

Author  Topic 

sarai
Starting Member

6 Posts

Posted - 2007-03-12 : 14:38:29
Hello,
I am trying to create a table with ID field which increment automatically. ID must be 6 charters contain both letters and numbers (A00A00)

i.e. A00A00, A00A001 ….. A00A99, A00B01 and so on

I try to generate and update table with unique ID s by writing a trigger and updating ID field by calling a function. This work fine when I try to insert a single row, but I am having problem updating ID when trying to insert multiple rows at same time i.e. inserts into statement.

The function (which calculate next id), check same table, find last ID value and increment the id according to formula. The main problem with multiple rows is that there is no way to know which last ID was used. Is there any other way to create a column with increment charters ID, which following ( i.e. A00A00, A00A001 ….. A00A99, A00B01 and so on) format? Note: ID must be 6 charters contain both letters and numbers (A00A00)

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-03-12 : 15:06:23
Dupe http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=80468
Go to Top of Page
   

- Advertisement -