|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to SET IDENTITY INSERT ON on a linked server?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 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... 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.Hi -- Regards Steen Schlüter Persson Databaseadministrator / Systemadministrator 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 I'm trying to insert a number of records into a linked server. One ofnews:%23RoZyIDyGHA.1340@TK2MSFTNGP05.phx.gbl... Hi 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 Tom Moreau wrote:
> You may be able to get away with it by placing all of the required commands ....of course.....why didn't I think about that...:-(.> inside a string and executing via: > > exec MyLinkedServer.MyDB.dbo.sp_executesql ... > > Thanks for the help. -- Regards Steen Schlüter Persson Databaseadministrator / Systemadministrator |
|||||||||||||||||||||||