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.
| Author |
Topic |
|
sandaire
Starting Member
5 Posts |
Posted - 2009-01-23 : 04:40:08
|
| Hello:I am trying to generate a unique consecutive value with SQL Server. My intent is to derive the following:A00001A00002...A00010...A00100etc...Is there a way to generate this value in SQL?Tks,Johnny |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-23 : 04:44:57
|
| select 'A000' + cast(number as varchar(32)) from master..spt_values where type = 'p' |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-01-23 : 04:46:04
|
quote: Originally posted by bklr select 'A000' + cast(number as varchar(32)) from master..spt_values where type = 'p'
Bklr but it ends with A0002047 after that it will not generate.... |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-23 : 09:26:39
|
| why not use an identity column and then create a computed value based on that? |
 |
|
|
sandaire
Starting Member
5 Posts |
Posted - 2009-01-27 : 10:14:26
|
| The identiy column worked great. I used a combination of the instructinos rom Lumbago and Visakh16 to create the solution. Tks! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-27 : 12:11:03
|
welcome |
 |
|
|
|
|
|