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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Creating Identity with variables

Author  Topic 

svicky9
Posting Yak Master

232 Posts

Posted - 2006-06-28 : 12:16:34
Hi Friends

I have a table which i want to enter one of the columns like

LB01
LB02
LB03

I want to create the identity with the coloum

how do i proceed

Vic

nr
SQLTeam MVY

12543 Posts

Posted - 2006-06-28 : 12:19:59
identity has to be numeric.
If LB is a constant why hold it in the table - just think of it as a client thing to concatenate.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-06-28 : 12:30:07
Basically you can't create a non-integer identity column but you can try the following workaround:

create table #test
( a int identity(1,1), -- only for internal reference
b as (case when isnull(a,0) < 10 then 'LB0' else 'LB' end) + convert(varchar(50),isnull(a,0)), -- this will be the column you use
.
.
.
)

The trick here is to use computed column. I hope i am clear !

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-06-28 : 13:43:19
quote:
Originally posted by svicky9

Hi Friends

I have a table which i want to enter one of the columns like

LB01
LB02
LB03

I want to create the identity with the coloum

how do i proceed

Vic



How do you proceed...by giving us more info..

Read the hint link in my sig, and post what it asks for



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-29 : 01:38:49
quote:
Originally posted by svicky9

Hi Friends

I have a table which i want to enter one of the columns like

LB01
LB02
LB03

I want to create the identity with the coloum

how do i proceed

Vic


See if this helps
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57069

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

svicky9
Posting Yak Master

232 Posts

Posted - 2006-06-29 : 08:25:14
Thanks Madhivanan ...your post seems to be helpful

Vic
Go to Top of Page
   

- Advertisement -