Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2003, 03:59 AM
Authorized User
 
Join Date: Sep 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default getting the result of an SQL INSERT

Hi everyone,

How can I get the results of the last insert. I have a stored procedure that inserts data in a table and I want to get the ID of the inserted data. However, I did not find any documentation that deals with any such SQL function like currval() or something like that.

Any help would be greatly appreciated.

Thanks,
Pankaj
 
Old September 30th, 2003, 04:12 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Assuming ID is an identity then you can use IDENT_CURRENT('table_name')
OR

@@Identity.

Check BOL for further information.

Nickie
 
Old September 30th, 2003, 04:25 AM
Authorized User
 
Join Date: Sep 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks man...@@IDENTITY worked just fine :)

Pankaj






Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView and SQL More than one result = one result DarkForce ASP.NET 2.0 Basics 0 July 20th, 2007 04:29 AM
result of SP to be insert into table drachx SQL Server 2000 1 October 3rd, 2005 12:38 AM
Fetching a value in a SQL result... IP076 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 November 29th, 2004 02:26 PM
How to read SQL Result mrideout BOOK: Beginning ASP.NET 1.0 1 October 20th, 2004 01:10 AM
check the result of sql query Abhinav_jain_mca ADO.NET 2 August 11th, 2004 11:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.