Related Functions
It is often useful or necessary to know what identity value was generated by an INSERT command. Microsoft SQL Server provides several functions to do this: @@IDENTITY provides the last value generated on the current connection in the current scope, while IDENT_CURRENT(tablename) provides the last value generated, regardless of the connection or scope it was created on.
Example:
INSERT INTO Contacts ( FirstName, LastName ) VALUES ( 'Test', 'User' ) -- SELECT @@IDENTITY -- OR -- DECLARE @ID INT SELECT @ID = @@IDENTITY UPDATE Contacts SET Phone = 'XXX-YYY-ZZZZ' WHERE ContactID = @IDRead more about this topic: Identity Column
Famous quotes containing the words related and/or functions:
“Perhaps it is nothingness which is real and our dream which is non-existent, but then we feel think that these musical phrases, and the notions related to the dream, are nothing too. We will die, but our hostages are the divine captives who will follow our chance. And death with them is somewhat less bitter, less inglorious, perhaps less probable.”
—Marcel Proust (18711922)
“Mark the babe
Not long accustomed to this breathing world;
One that hath barely learned to shape a smile,
Though yet irrational of soul, to grasp
With tiny fingerto let fall a tear;
And, as the heavy cloud of sleep dissolves,
To stretch his limbs, bemocking, as might seem,
The outward functions of intelligent man.”
—William Wordsworth (17701850)