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 |
sheena
Starting Member
45 Posts |
Posted - 2007-04-06 : 02:57:06
|
Hello Members, Is it fine to create the unique sequence number id using the int or uniqueidentifier field ? I want to further generate the id sequence id like with that consisting of the table initials with id to differ from other id.Like,i m having a table name of employee then it should have thewhere it is primary key and also in other table where it is foreign key.e001.........ore01...........ore1............which gets differ from the other.If i select the field which is alphanumeric like char or varchar then there's no autoincrement in id.Is there any way for this solution.If anyone know then pls kindly reply me.I think it can be solve with substring function but i don't have the exact idea how to use it...I m using asp.net with C# 2005 and sql server 2005.So,if possible then pls kindly give some solution which is related to C#.Have already created the autogenerated id and stored in database.I m using stored procedure for insert of the data.Thanxs in advance for a reply.. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-06 : 06:44:45
|
What happens after z999?Peter LarssonHelsingborg, Sweden |
 |
|
sheena
Starting Member
45 Posts |
Posted - 2007-04-06 : 12:58:02
|
Actually i m creating a small application where there are no much records which can go beyond the limit of 999.But,then to for the easiness i want to create the id as described above but don't have much idea.If anyone can guide id beyond 999 or upto 999 then pls reply...thanxs |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
sheena
Starting Member
45 Posts |
Posted - 2007-04-08 : 10:40:31
|
thanxs for the link...it's the same question and answered as i want...but before using it i want to ask some questions and clear my doubts...1) So,i have to take the id field as varchar instead of int.No need to create the identity ??2)For each select,insert,update and delete i have to use the substring function. Can u pls explain me in simple way,if possible with my example, if i have a employee table withemployee id int(4) IDENTITY=Yes + 1employee namedesignationsalarythen i have to create the other temp table or what ??--------------------------------------------------------------------------YOUR LINK EXAMPLE ::declare @s varchar(10)set @s='PRS001'select left(@s,3)+right('00'+cast(max(substring(@s,4,len(@s))+1) as varchar),3)==========================create table testtbl(vno char(9))declare @vno varchar(4)declare @no int--------------------------------------------------------------------------Thanxs for ur answers and waiting for ur another replies....Pls help me out... |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-10 : 05:14:30
|
Make that column as varchar and increment it whenever data are addedMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|