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 |
|
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2008-01-15 : 01:59:50
|
| Hi,i am using sql server 2005.i am making doctor maaster(which also store the data that are other then doctor like nurses etc)i have to generates doctor id as dr00001 , next record dr00002 and so on i am also using other details in the same table whose id should be ot00001 , ot00002 and so on ....i would like to know is it possible to generates this type of structure automatically like identity column generates auto number.can we design the table in such manner that it generates the id in specified manner.please help.thank you |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-01-15 : 02:12:17
|
you could have a regular identity column, and then a separate computed column somethign like this:create table #mytable( id int identity(1,1) primary key ,name varchar(10) not null ,computedCol as 'dr' + right('00000' + convert(varchar,id), 5))insert #mytable(name) select 'asdf' union all select 'qwert'select * from #mytabledrop table #mytablealso have a look here: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server elsasoft.org |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|