Displaying keyword search results 1 - 2
Created by Dr. Xi on August 31, 2008 20:43:44 Last update: January 22, 2011 12:48:08
Created by Dr. Xi on August 11, 2007 23:19:26 Last update: August 12, 2007 01:39:33
For SQL Server 2000 and above, there are three functions: SELECT @@IDENTITY When a record is inserted into a table with a identity column, the function @@IDENTITY returns the last identity value that was inserted in the database on the same open connection. If a trigger adds a record into another table, which happens to have an identity column, @@IDENTITY will now return this value instead. SELECT IDENT_CURRENT('tablename') This will give you the most recent identity value for the given table regardless of who inserted it. SELECT SCOPE_IDENTITY() SCOPE_IDENTITY shows the most recently inserted IDENTITY in the current scope (which ignores any triggers that might fire). For SQL Server version prior to 2000, it is customary to use a stored procedure:
CREATE PROCEDURE myProc @param1 INT AS......