Home All Groups Group Topic Archive Search About

How to SET IDENTITY INSERT ON on a linked server?

Author
25 Aug 2006 10:35 AM
Steen Persson (DK)
Hi

I'm trying to insert a number of records into a linked server. One of
the columns I'm trying to insert into, is an IDENTITY field so I need to
run SET IDENTITY INSERT ON for this. How do I do this for a linked
server? The SET IDENTITY INSERT ON statement only accepts the database
and table name - not the server name as identifier.


--
Regards
Steen Schlüter Persson
Databaseadministrator / Systemadministrator

Author
25 Aug 2006 10:44 AM
Immy
Steen,

you cannot do this (as far as I'm aware).
The set statement is 3 part and not 4 part.

An idea - you could create a stored procedure on the linked server that sets the identity value off and on, then you could call the procedure before executing your insert statetment?

Immy
  "Steen Persson (DK)" <s**@REMOVEdatea.dk> wrote in message news:%23RoZyIDyGHA.1340@TK2MSFTNGP05.phx.gbl...
  Hi

  I'm trying to insert a number of records into a linked server. One of the columns I'm trying to insert into, is an IDENTITY field so I need to run SET IDENTITY INSERT ON for this. How do I do this for a linked server? The SET IDENTITY INSERT ON statement only accepts the database and table name - not the server name as identifier.


  --
  Regards
  Steen Schlüter Persson
  Databaseadministrator / Systemadministrator
Author
25 Aug 2006 11:05 AM
Tom Moreau
You may be able to get away with it by placing all of the required commands
inside a string and executing via:

exec MyLinkedServer.MyDB.dbo.sp_executesql ...

--
   Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON   Canada
..
"Steen Persson (DK)" <s**@REMOVEdatea.dk> wrote in message
news:%23RoZyIDyGHA.1340@TK2MSFTNGP05.phx.gbl...
Hi

I'm trying to insert a number of records into a linked server. One of
the columns I'm trying to insert into, is an IDENTITY field so I need to
run SET IDENTITY INSERT ON for this. How do I do this for a linked
server? The SET IDENTITY INSERT ON statement only accepts the database
and table name - not the server name as identifier.


--
Regards
Steen Schlüter Persson
Databaseadministrator / Systemadministrator
Author
25 Aug 2006 11:32 AM
Steen Persson (DK)
Tom Moreau wrote:
> You may be able to get away with it by placing all of the required commands
> inside a string and executing via:
>
> exec MyLinkedServer.MyDB.dbo.sp_executesql ...
>
>  
....of course.....why didn't I think about that...:-(.

Thanks for the help.


--
Regards
Steen Schlüter Persson
Databaseadministrator / Systemadministrator

AddThis Social Bookmark Button