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 |
t1g312
Posting Yak Master
148 Posts |
Posted - 2003-11-29 : 03:22:43
|
Hi all,I need to generate a unique job number for each record which should be alphanumeric. I can't use autonumber because it generates only numbers. How do I go about it?TIA |
|
SqlStar
Posting Yak Master
121 Posts |
Posted - 2003-11-29 : 03:31:41
|
Hi,Alphanumeric means, that alphabet character comes from where? its like first character of employee's Last Name or else? If you want to reset that autonumber for each character or continues number?(i.e., irrespective of character)Send me answer for my questions.I hope its possible.":-) IT Knowledge is power :-)" |
|
|
xpandre
Posting Yak Master
212 Posts |
Posted - 2003-11-29 : 03:33:32
|
use newid()create table t1( id uniqueidentifier not null default newid()) |
|
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2003-11-29 : 04:36:09
|
quote: Originally posted by SqlStar Hi,Alphanumeric means, that alphabet character comes from where? its like first character of employee's Last Name or else? If you want to reset that autonumber for each character or continues number?(i.e., irrespective of character)Send me answer for my questions.I hope its possible.":-) IT Knowledge is power :-)"
Thanks for the quick reply. It will be 1 character (most probably J) followed by the number. All I need is a unique number and doesn't matter if they are continuous or not. |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2003-11-29 : 04:46:28
|
Why bother at all with the character in the base table if is going to be a constant?. Use an IDENTITY column, then create a view that converts the number to a string and then add whatever characters you like. The users won't know the difference.DavidM"SQL-3 is an abomination.." |
|
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2003-11-29 : 05:22:48
|
quote: Originally posted by byrmol Why bother at all with the character in the base table if is going to be a constant?. Use an IDENTITY column, then create a view that converts the number to a string and then add whatever characters you like. The users won't know the difference.DavidM"SQL-3 is an abomination.."
Good idea! I am using VB as my front-end. What I'll do is display the character along with the generated number in the text field. Thanks again! |
|
|
|
|
|