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
 Transact-SQL (2000)
 how to use formula for identity column ?????

Author  Topic 

SanjaySutar
Starting Member

18 Posts

Posted - 2008-03-25 : 08:41:24
Hi ,
i just want to know how to create a formula for generating
unique alphanumeric key for primary key set as identity using
formula option.


thanx in advance

San

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-25 : 08:44:39
You can't.
However you can use INT for IDENTITY column and then make a unique calculated column based on the identity value.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-25 : 09:28:51
see:

http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-02 : 06:46:01
Also refer http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=57069

Madhivanan

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

Chas
Starting Member

2 Posts

Posted - 2008-04-02 : 22:15:34
The anwers of the others are much more comprehensive, but this is what I use to generate unique numbers:

ALTER PROCEDURE RPNdxUpdate
AS
SET NOCOUNT ON
UPDATE rp1
SET ndx =
(SELECT COUNT(rp2.[OFF])
FROM dbo.RP rp2
WHERE (rp2.Date + rp2.[OFF]) < (rp1.Date + rp1.[OFF]))
FROM dbo.RP rp1
RETURN

In the RP table the Date and [Off] columns are never null and in combination are always unique.

Chas
Go to Top of Page
   

- Advertisement -