Rilcon42
Rilcon42

Reputation: 9763

Cant add table to database via linked server

I am trying to add a table to an existing database in a linked server, but getting:

The object name 'name.mycompany.com.DataAg.dbo.Secure30AWSMap' contains more than the maximum number of prefixes. The maximum is 2.

What am I doing wrong? Based on this link it seems like I cant use a 4 part name. However this link sounds like it might be a workaround using an Exec statement. Is there a way to solve this without messing with the linked servers DDL though?

create table [name.mycompany.com].[DataAg].[dbo].[Secure30AWSMap]([servername] [nvarchar](50),[username] [nvarchar](50),[full_name][nvarchar](50),[awscoid][nvarchar](50))

Upvotes: 0

Views: 94

Answers (2)

RGhanbari
RGhanbari

Reputation: 134

if RPC is configured true for linked server, it can help.

EXEC('create table [DataAg].[dbo].[Secure30AWSMap]([servername] [nvarchar](50),[username] [nvarchar](50),[full_name][nvarchar](50),[awscoid][nvarchar](50))') AT [name.mycompany.com]

Upvotes: 1

Buchiman
Buchiman

Reputation: 320

You need to go to your linked server and manually create the table and then try this.

  INSERT INTO [linkedserver].[database].[dbo].[table]
SELECT servername, username, fullname, awscoid
FROM [database].[dbo].[table]
WHERE ID = userID;

Upvotes: 0

Related Questions