SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Unique Job Number
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

t1g312
Posting Yak Master

United Arab Emirates
148 Posts

Posted - 11/29/2003 :  03:22:43  Show Profile  Reply with Quote
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

USA
121 Posts

Posted - 11/29/2003 :  03:31:41  Show Profile  Reply with Quote
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

201 Posts

Posted - 11/29/2003 :  03:33:32  Show Profile  Reply with Quote
use newid()

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

t1g312
Posting Yak Master

United Arab Emirates
148 Posts

Posted - 11/29/2003 :  04:36:09  Show Profile  Reply with Quote
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

Australia
1591 Posts

Posted - 11/29/2003 :  04:46:28  Show Profile  Reply with Quote
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

United Arab Emirates
148 Posts

Posted - 11/29/2003 :  05:22:48  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000