Click here to Skip to main content
15,897,170 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi folks,

i just wonder how to make the data types with alphanumeric value, that will be used in the database and will be set as the primary key. the usual data type used whenever setting the primary key is in Autonumber, and when used will basically stored numbers accordingly (1 2 3...). Could it be possible to set the data types with letters? (Ex format: PS0001/PS1/PS-1) and will continually set the numbers accordingly like Autonumber, with the PS connected to it?

hope you get my point (though kinda hard to explain it)
thanks a lot!
Posted

1 solution

For alphanumeric data you can use varchar Datatype, But "Identity" works with int/numeric Datatype. "Identity" has a two parameters seed and increment both requires numeric values. By default their values are (1,1).

Have a look at below link for more details on "Identity".

http://msdn.microsoft.com/en-us/library/ms186775.aspx

You need to write your custom logic in either Stored Procedure or .Net code for your incremented alphanumeric values.
 
Share this answer
 
Comments
Espen Harlinn 7-Nov-11 11:23am    
5'ed - OP only need to use formatting to get what he wants
RaisKazi 7-Nov-11 11:28am    
Thank you once again Espen. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900