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)
 Unique Job Number

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 :-)"
Go to Top of Page

xpandre
Posting Yak Master

212 Posts

Posted - 2003-11-29 : 03:33:32
use newid()

create table t1
( id uniqueidentifier not null default newid()
)
Go to Top of Page

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.
Go to Top of Page

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.."
Go to Top of Page

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!
Go to Top of Page
   

- Advertisement -