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
 SQL Server Development (2000)
 Auto Increment for varchar ???

Author  Topic 

GiriC
Starting Member

2 Posts

Posted - 2006-02-28 : 12:02:57
Hello,

I have a cursor that opens all the records in a table.

I need to generate a string like this "MSFT" + STATE + xx (can be ASCII sequence )

State ABBREVIATION comes from the cursor.

How do I generate sequence like

MSFTVA00
MSFTVA01
MSFTVA02
..............
MSFTVA09
MSFTVA0A
MSFTVA0B.........
MSFTVA0Z
I can use only 2 spaces but I need to have as many distinct numbers
in those last 2 spaces available

Any ideas are appreciated.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-02-28 : 13:27:45
We can come up with a way to generate a sequence of (hex-like) characters but are you willing to think about alternative solutions?

It is not a good strategy to concatenate multiple values along with a sequence (converted to characters) to act as a code or key. Can you use seperate columns to store the values and use a "natural" combination of these columns as the primary key (or unique) key? Alternatively, can you use an integer identity column to act as your sequence and the seperately store the other facts?

Be One with the Optimizer
TG
Go to Top of Page

activecrypt
Posting Yak Master

165 Posts

Posted - 2006-02-28 : 23:33:44
Hi,
true said but if its only requirement you can refer
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57069

Andy Davis
Sql Shield Team
--------------------------------------------
SQL Server Encryption Software
http://www.sql-shield.com
Go to Top of Page
   

- Advertisement -