September 5, 2006 at 7:18 am
Hey, this is my first post.
http://www.sqlservercentral.com/forums/images/emotions/blush.gif .
I am developing a integration protype and I am assigning a "make beleive" primary key, which I currently do by assigning a counter number in a cursor. This works fine....but the next time around the program runs I want the counter to start at + 1 from the last number assigned. Any suggestions would be apprecaited.
Thanks,
Jay
September 5, 2006 at 7:44 am
Why not use an identity column?
You can always use something like this... but you must lock the table for inserts when you do this :
Select @MyNewID = ISNULL(MAX(IdCol), 0) + 1 from dbo.Mytable
Insert into dbo.Mytable (IdCol) VALUES (@MynewID)
September 5, 2006 at 8:06 am
The easy way to lock this is use a transaction around it.
Begin transaction
...
commit
September 5, 2006 at 10:31 am
Thanx... forgot to type that .
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply