Pho3nix
The Legend
Happy New Year all 
Trying to fix a colleagues problem code while he is away and not getting much joy
Below is the pseudo variant of it. Any assistance would be appreciated.
Current Error is :
Or this when I remove the SET IDENTITY_INSERT lines :
Trying to fix a colleagues problem code while he is away and not getting much joy
Below is the pseudo variant of it. Any assistance would be appreciated.
Code:
DECLARE @valueCheck INT;
DECLARE @ProdServer INT;
DECLARE @QAServer INT;
DECLARE @DevServer INT;
SET @valueCheck = 0;
SET @ProdServer = (select COUNT(*) from [server1].DB1.dbo.Table1);
SET @QAServer = (select COUNT(*) from [server2].DB1.dbo.Table1);
SET @DevServer = (select COUNT(*) from DB1.dbo.Table1);
BEGIN IF @ProdServer = @valueCheck
BEGIN IF @QAServer > @ProdServer
SET IDENTITY_INSERT server1.DB1.[dbo].[Table1] ON;
INSERT INTO [server1].DB1.[dbo].[Table1]
SELECT * FROM [server2].DB1.dbo.Table1;
SET IDENTITY_INSERT [server1].DB1.[dbo].[Table1] OFF;
END
BEGIN IF @DevServer > @ProdServer
INSERT INTO [server1].DB1.[dbo].[Table1]
SELECT * FROM DB1.PBBLanding.Table1;
END
END
BEGIN IF @QAServer = @valueCheck
BEGIN IF @QAServer < @ProdServer
INSERT INTO [server2].DB1.[dbo].[Table1]
SELECT * FROM [server1].DB1.dbo.Table1;
END
BEGIN IF @DevServer > @QAServer
INSERT INTO [server2].DB1.[dbo].[Table1]
SELECT * FROM DB1.dbo.Table1;
END
END
Current Error is :
Code:
The object name 'server1.DB1.dbo.Table1' contains more than the maximum number of prefixes. The maximum is 2.
Or this when I remove the SET IDENTITY_INSERT lines :
Code:
The OLE DB provider "SQLNCLI10" for linked server "EMPPRODMISSQL\PMIS001,50002" could not INSERT INTO table "[EMPPRODMISSQL\PMIS001,50002].[MIAnalyticStaging].[PBBLanding].[AfricaProjectsSharePoint]" because of column "UniqueId". The user did not have permission to write to the column.
Last edited: