Get @@identity from remote database

Last Post 03 Jul 2007 04:16 AM by paulgravestock. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
paulgravestock
New Member
New Member

--
03 Jul 2007 03:42 AM
Hi all,

I am inserting into a remote table and need to get the identity value that was last created i.e.

insert into [RemoteServer].[RemoteDatabase].dbo.[DB](num)
values(1)
declare @id int
set @id = @@identity
select @id

This is returning NULL for the identity value but works fine if I run it on the server locally.

Does anyone know how to pick up the identity value?

Thanks,
Paul
paulgravestock
New Member
New Member

--
03 Jul 2007 04:16 AM
It would appear that this can't be done. I am going to use a remote procedure to do the insert and then return the identity value as a parameter.

You are not authorized to post a reply.

Acceptable Use Policy