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)
 Trigger in Sql server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-10-03 : 07:52:42
kamalkishore writes "Hai gurus

How to generate the values automatically in a primary key column without using sequence or identity in sql server using triggers or procedures."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-03 : 08:41:53
Declare @i int
Select @i=Isnull(max(col),0)+1 from yourTable
Insert into yourTable values(@i,.......)


Madhivanan

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

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-10-03 : 08:42:49
Why do you want to do that?
If the identity facility is there for you to use - rather use it.


Duane.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-10-03 : 13:08:17
Plus its not quite atomic, is it?

Kristen
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-10-03 : 13:23:34
asked and answered

http://weblogs.sqlteam.com/brettk/archive/2004/06/29/1687.aspx



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
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-10-03 : 22:22:46
plus in between processing can really mess up the sequencing for parallel transactions


quote:
Originally posted by Kristen

Plus its not quite atomic, is it?

Kristen



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -