Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autogeneration of Serial No. in SQL

Status
Not open for further replies.

pna3

Programmer
Dec 5, 2003
21
IN
I have a column named "Serial Number". I want the Serial Nos. to be auto generated. how do i do this?
 
Set it as an Identity field in Enterprise Manager
 
However, this SerialNo. needs to be displayed on a Visual Basic Screen. As and when every record gets saved the serialNo. should keep incrementing
 
I want the SerialNo. to be like for e.g "CC1" then "CC2"

if i use identity it would only generate nos. like "1", "2", etc.

how do i get SerialNos. like
CC1
CC2
CC3
CC4
CC5
 
well you could get it to use a default to make the code for you on insert or if the prefix of your serial number doesnt change then u could just put an input mask on it in you VB app.




 
You could create a trigger that upon an insert finds the MAX(SerialNumber) and adds 1 to it.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top