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)
 Sql Unique Id or Number generator..

Author  Topic 

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2008-09-10 : 02:12:22
Hey,,,,can any one help me in this,,,
i want a store procedure with generates a Unique No. or id when a new row is inserted in it by the asp.net form..
dont like to use the Identity method...


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-10 : 02:13:46
use newid()


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-09-10 : 09:20:19
what's wrong with identity?


elsasoft.org
Go to Top of Page

Cornelius19
Starting Member

30 Posts

Posted - 2008-09-11 : 16:36:11
I would definitely use IDENTITY for that; it seems to me simple and efficient - is not it?

CREATE TABLE [MyTable] (
[id] [bigint] IDENTITY (1, 1) NOT NULL ,
[F1] [varchar] (400) COLLATE Latin1_General_CS_AS NULL
)
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2008-09-13 : 02:39:55
Hi thanks to all of u Guys....
If all of my purposes solve with the help of identity than i definitely use it But as u know all as if i delete a record from that table,,,than If i use Identity than it never assigns that coloumn value again,,,
so i want to avoid that thing,,,,,,,
i want all the records in a sequence ,,,,,so tell me another method or store procedure to do this,,,,,
thanks in adv,
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-09-14 : 12:59:14
No matter what method you use to assign a unique number, you will still have a gap in the sequence if you delete a row.

Any method besides identity that you use will be more resource intensive and limit the scalability of your applicaiton.



CODO ERGO SUM
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-14 : 13:46:30
quote:
Originally posted by ashishashish

Hi thanks to all of u Guys....
If all of my purposes solve with the help of identity than i definitely use it But as u know all as if i delete a record from that table,,,than If i use Identity than it never assigns that coloumn value again,,,
so i want to avoid that thing,,,,,,,
i want all the records in a sequence ,,,,,so tell me another method or store procedure to do this,,,,,
thanks in adv,


But you shouldnt really be worrying about missing numbers in between. You can still retrieve the existing records based on the order of identity column.
Go to Top of Page
   

- Advertisement -