Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a table on a linked server?

Is it possible to create a table on a linked server?

like image 349
user329592 Avatar asked May 03 '10 09:05

user329592


People also ask

How do I select a linked server table?

1 Open SQL Server Management Studio, navigate to the Object Explorer pane, and select Server Objects > Linked servers > Providers. 2 Right-click mrOledb. Provider and select Properties. 3 Select allow in process, and then click OK.

What is the use of linked server in SQL?

Linked servers enable the SQL Server Database Engine and Azure SQL Managed Instance to read data from the remote data sources and execute commands against the remote database servers (for example, OLE DB data sources) outside of the instance of SQL Server.

Can we create linked server in MySQL?

Unfortunately you cannot link an entire MySQL database to another MySQL database like you can with MS SQL. However, you can link individual tables. A federated table is a local table you create that points to a table on another server. You can run queries and stored procedures just like any other table.


1 Answers

The solution from Arpit works fine.

exec

('CREATE TABLE DatabaseName.dbo.TableName
(
  column1 datatype,
  column2 datatype,
  column3 datatype
)') at [LinkedServer];
go

How ever, when you get the error "Msg 7411, Level 16, State 1, Line 1 Server 'MyLinkedServer' is not configured for RPC." you need to change the RPC-parameters on the linked server connection. As default RPC is set to false. It needs to be set to true.

Linked server options

This allows you to run procedures on the linked server. You must allow this because the solution does not send the "Create table" statement as a SQL command to the linked server. It sends the statement as a string which in turn is executed as a procedure on the remote server.

Hope this helps.

like image 120
Mikkel Tronsrud Avatar answered Oct 18 '22 17:10

Mikkel Tronsrud