Linked server and identity_insert

  • hi all -

    I am trying to move some data from test to prod. On my test server I have the prod server as a linked server.

    INSERT INTO [prodSERVER\F].[DB].[dbo].

    ([ReportID]

    ,[ReportName]

    ,[ReportDesc])

    SELECT [ReportID]

    ,[ReportName]

    ,[ReportDesc]

    FROM [TESTSERVER].[SCHEMA].

    Several of the tables in testserver have identity columns. I'm trying to use set IDENTITY_INSERT [prodSERVER\F].[DB].[dbo].

    ON

    --GO

    as the first step in the data transfer for each table, then flipping it back off before doing the next, etc. It appears that you can't use that when going through a linked server? Is that correct or am I missing something?

    thanks

  • You'd have to switch it around:

    --Run on prod server

    set IDENTITY_INSERT [dbo].

    ON

    INSERT INTO [dbo].

    ([ReportID]

    ,[ReportName]

    ,[ReportDesc])

    SELECT [ReportID]

    ,[ReportName]

    ,[ReportDesc]

    FROM [TESTSERVER].[db].[SCHEMA].

    And just add the linked server from your prod box to the test server.

  • yep, that's what I was afraid of... expensive lesson learned.

    thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply