linked-server

error when insert into linked server

喜欢而已 提交于 2019-12-28 13:34:52
问题 I want to insert some data on the local server into a remote server, and used the following sql: select * into linkservername.mydbname.dbo.test from localdbname.dbo.test But it throws the following error The object name 'linkservername.mydbname.dbo.test' contains more than the maximum number of prefixes. The maximum is 2. How can I do that? 回答1: I don't think the new table created with the INTO clause supports 4 part names. You would need to create the table first, then use INSERT..SELECT to

The operation could not be performed because OLE DB provider “SQLNCLI10” for linked server “DB_PROD_04” was unable to begin a distributed transaction

爱⌒轻易说出口 提交于 2019-12-25 11:55:09
问题 I have two servers: SQL_UAT_01 DB_PROD_04 Both of these servers have the same database name and same tables: SQL_UAT_01.Database_01.TestTable DB_PROD_04.Database_01.TestTable There is a trigger on each of these two tables. When the trigger fires, it does a simple UPDATE on the table of the OTHER server. Example Trigger is fired here: SQL_UAT_01.Database_01.Test It does an update here: DB_PROD_04.Database_01.Test And vice-versa. I'm running into an error which I have no clue how to fix. Again,

EF Core: Use Linked Server to Oracle database issue

允我心安 提交于 2019-12-25 00:06:08
问题 In another question, I need to use ASPNET BoilerPlate (EF Core template) with the Oracle database but it does not support so far. So I tried to use SQL Server with Linked Server to Oracle database. What I have tried: Create Linked Server named "LinkedOracle" from SqlServer to Oracle database Create a SqlServer database named "FakeOracleDb" and create Views to LinkedOracle tables by: CREATE VIEW CUSTOMER AS SELECT * FROM LinkedOracle..MYUSER.CUSTOMER Now I have a fake SQL Server database that

How to capture error message returned from linked server?

断了今生、忘了曾经 提交于 2019-12-24 09:44:39
问题 How can I capture an error message returned from a linked server? As an example, if I run the following command in SQL Server Management Studio: BEGIN TRY exec ('select * from xxx') at my_linked_server END TRY BEGIN CATCH print 'ErrorNumber...'+ CAST(ERROR_NUMBER() as varchar) print 'ErrorSeverity...'+ CAST(ERROR_SEVERITY() as varchar) print 'ErrorState...'+ CAST(ERROR_STATE() as varchar) print 'ErrorProcedure...'+ IsNull(ERROR_PROCEDURE(),'') print 'ErrorLine...'+ CAST(ERROR_LINE() as

SQL Server Error: Could not execute remote procedure

谁说我不能喝 提交于 2019-12-24 08:35:06
问题 I have three SQL Server 2008 boxes, call them A, B & C. Servers A & B each have a linked server to server C. The linked servers use the exact same linked server setup on both A & B. Both connect to C using the exact same login information. The login has the sysadmin role assigned to it on box C. Both were configured with RPC and RPC OUT set to true. Both can perform SELECT, INSERT, UPDATE, DELETE with no problems whatsoever. C has Allow remote connections and Require distributed transactions

Linked server INSERT, UPDATE and DELETE fails with “Unknown provider error”

牧云@^-^@ 提交于 2019-12-24 08:09:43
问题 Suddenly INSERT, UPDATE and DELETE fails for a certain file (a table in a remote system which I believe is an AS/400). The linked server that we make use of is set up in SQL Server, and it's using an ODBC data source (DSN). The Data source is an "ODBC-data source for iSeries Access for Windows". Only one single table has this problem. We can make inserts and updates in other tables using the same linked server, without any errors, and SELECTs still work for the problematic table. We get these

Testing linked server conccetion inside trigger or procedure

怎甘沉沦 提交于 2019-12-24 06:45:23
问题 I wrote a trigger that updates local table and similar table on linked server. CREATE TRIGGER myTtableUpdate ON myTable AFTER UPDATE AS IF (COLUMNS_UPDATED() > 0) BEGIN DECLARE @retval int; BEGIN TRY EXEC @retval = sys.sp_testlinkedserver N'my_linked_server'; END TRY BEGIN CATCH SET @retval = sign(@@error); END CATCH; IF (@retval = 0) BEGIN UPDATE remoteTable SET remoteTable.datafield = i.datafield FROM my_linked_server.remote_database.dbo.myTable remoteTable INNER JOIN inserted i ON

How to fetch data from two different sql servers?

扶醉桌前 提交于 2019-12-23 18:09:40
问题 I have an inline query, in which I have one table1 in server1 and another table2 in server2. I need to join these two tables, and fetch data. I can do this like connect to one server, get data and connect to next server...fetch data. and join them. But is there any other better way. I have heard about Linked servers. Will that help here ? Thanks in advance !!! 回答1: Yes, set up a linked server on one server to the other. Then you can just do a normal query with a join. It would look something

Problem with SQL subquery using Top() on Linked Server

别来无恙 提交于 2019-12-23 15:27:53
问题 I am using SQL Server 2008 and I have the following SQL script: Select o.CustomerId as CustomerNoId, OrderValue, OrderDate From dbo.Orders as o Inner Join ( Select Top (10) CustomerId From dbo.Customers where Age < 60 ) As c On c.CustomerId = o.CustomerId This works as desired when used with dbo.Customers and dbo.Orders on the local SQL Server instance. It returns all rows from the orders table for the first 10 customerIds returned from the the Customers table - 1688 rows. However I have a

Selecting a column with period in the column name SQL Server

偶尔善良 提交于 2019-12-23 11:59:09
问题 I am linked to a Proficy Historian that allows periods in the column names. Because the data is stored in a non DBMS format I can not use openquery to get the data because there is no set schema to the tables. So I must use four part name syntax to get the data. This example works: SELECT * FROM iHist...[SELECT * FROM ihTrend] but this fails with Incorrect syntax near '.'. SELECT * FROM iHist...[SELECT [SERVER.pid_astatus[07][0].F_CV.Value] FROM ihTrend] where SERVER.pid_astatus[07][0].F_CV