Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 get multiple @identity as output from sqlserver

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-05-09 : 08:27:26
Anjin Pradhan writes "I have used this stored proceedure to insert multiple data in a database. Now i want to get the identitys of all the records that i have inserted how is this possible

CREATE procedure usp_InsertManyRows

@XMLDOC text
AS
declare @xml_hndl int
BEGIN TRANSACTION TransactionName

exec sp_xml_preparedocument @xml_hndl OUTPUT, @XMLDOC

Insert Into testtable
(
InsertedID
)
Select
IDToInsert
From
OPENXML(@xml_hndl, '/items/item', 1)
With
(
IDToInsert int '@id'
)

select * from testtable where id=@@identity

COMMIT TRANSACTION TransactionName
GO
"
   

- Advertisement -