You are here: Re: IDENT_CURRENT problem « MsSQL Server « IT news, forums, messages
Re: IDENT_CURRENT problem

Posted by Tom Moreau on 03/21/06 18:17

Use SCOPE_IDENTITY().

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"john" <j_stus@hotmail.com> wrote in message
news:1142956990.537887.205610@j33g2000cwa.googlegroups.com...
Hi there
I have small problem with IDENT_CURRENT...
We have a table where PK is generated automatically.
What I want is to get that value and insert it to another,
corresponding table.
So here is what I am doing...
BEGIN TRAN
Insert Into table() --> PK is created.
SELECT IDENT_CURRENT('Table_Name') AS lastValue
COMMIT TRan

IT works fine, but there is a possibility to insert another record by
another user before I get my IDENT_CURRENT.
For instance:
BEGIN TRAN
Insert Into table() --> PK is created.
---->somebody else inserts another record into same table.
SELECT IDENT_CURRENT('Table_Name') AS lastValue
---->this is not the value that I generated....
COMMIT TRan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация