I have table A on server A that has a set of user data columns. I need to insert this into table B on server B. I wrote a stored procedure to run this insert statement every night (SQL below). If I select and execute any part of the procedure, then it works fine, but if I try to execute the procedure as a whole, then it will give me an error:
The object name ServerB.DatabaseB.dbo.TableB has more than the maximum number of prefixes. maximum 2.
T-SQL operation:
IF EXISTS (SELECT * FROM SERVERA.DatabaseA.dbo.TableA) BEGIN TRUNCATE TABLE SERVERB.DatabaseB.dbo.TableB INSERT INTO SERVERB.DatabaseB.dbo.TableB SELECT Firstname, Surname, Username FROM SERVERA.DatabaseA.dbo.TableA END
Does anyone have any ideas what I'm doing wrong?
source share