RSS

Getting the Identity of the last Inserted row

22 Jul

hi..

If you want to get the identity of the table at the time of insert ,so use this sp
create PROCEDURE [dbo].[EmployeeData_Insert]

@FirstName    varchar(100),
@LastName    varchar(100),
@Title    varchar(10),
@DateCreated    smalldatetime,
@DateModified    smalldatetime

AS

INSERT INTO [employeeData]
(
[FirstName],
[LastName],
[Title],
[dateCreated],
[dateModified]

)
VALUES
(
@FirstName,
@LastName,
@Title,
@DateCreated,
@DateModified

)

declare @_id_EmployeeID_ int
set @_id_EmployeeID_ = @@IDENTITY

SELECT
[employeeID]
FROM [employeeData]
WHERE
[employeeID] = @_id_EmployeeID_

Advertisements
 
Leave a comment

Posted by on July 22, 2011 in SQL Query

 

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: