linked-server

How to insert a row into a linked server table?

懵懂的女人 提交于 2019-12-08 17:23:10
问题 I have a server SourceServer I am connected to which has a linked server TargetServer. How should an insert statement looks like (I need to reference Linked server, database, namespace, table): //Connected to [SourceServer] USE [SourceDatabase] DECLARE @HelloWorld NVARCHAR(255) SELECT @HelloWorld = Name From dbo.Names where Id = 1 INSERT INTO [TargetServer].[TestDatabase].dbo.TestTable (Name) VALUES (@HelloWorld) This statement executes with an exception: Too many prefixes. Update: The syntax

“Deferred prepare could not be completed” error when using local database as linked server

风格不统一 提交于 2019-12-08 14:32:06
问题 I created a Linked Server from my local Sql Server, as given in http://sqlserverplanet.com/dba/local-linked-server However when I try to execute a stored procedure in Linked Server, it throws: Deferred prepare could not be completed error and invalid object name 'table name' 回答1: Have you missed something in your object name. It should be always like Database.User.ObjectName (for e.g. Northwind.dbo.Customers) Give complete object name when running queries via Linked servers. Query for Stored

Transaction with loopback linked server - locking issues

久未见 提交于 2019-12-08 09:52:22
问题 I have two databases A and B . They are both stored on one database instance. I created a loopback linked server on the instance. Database A contains one table dbo.Users and one stored procedure updating dbo.Users table. In database B I have a query which does two things: Execute the stored procedure from database A which updates the dbo.Users table. Select data from dbo.Users through the linked server. BEGIN TRANSACTION EXEC [LinkedServer].A.dbo.UpdateUser select * from [LinkedServer].A.dbo

Slow performance in linked server query

非 Y 不嫁゛ 提交于 2019-12-08 07:07:28
I'm using a Linked Server Query from MSSQL to mySql . MySql table to be queried has 800K + records I'm using a temp table to pull the results from linked server and do a join on that temp table for SQL query Is there a performance difference between: Declare @MyString varchar(max), @Address varchar(20), @tempTable (Address, ColumnB, ColumnC) set @MyString = 'Select Address, ColumnB, ColumnC from schemaname.tablename where ''' + convert(varchar(30),@Address) + ''') order by ColumnB desc limit 10' set @MyString = 'Select * from Openquery([My_Linked_Server], ''' + REPLACE(@MyString, '''', '''''')

SQL Server : openquery insert linked server

徘徊边缘 提交于 2019-12-08 05:52:37
问题 How do I insert data into a linked server (oracle) with a condition that a row does not exist? I want to insert into employee table if employeecode does not exist yet in that table INSERT INTO OPENQUERY(ORACLEX, 'SELECT EMPCODE, EMPNAME FROM AX.EMPLOYEE') -- I want a where clause here Select EID, ENAME FROM EMPDATA 回答1: You might actually have to read from the table twice INSERT INTO OPENQUERY(ORACLEX, 'SELECT EMPCODE, EMPNAME FROM AX.EMPLOYEE') -- I want a where clause here Select D.EID, D

SQL Linked server - Remote access error when executing SP

梦想的初衷 提交于 2019-12-08 04:00:43
问题 I've set up a linked server between an instance on SQL 2012 and SQL 2008R2 but I keep getting the below error when trying to execute a stored procedure on a remote server: Msg 7201, Level 17, State 4, Line 1 Could not execute procedure on remote server 'TEST' because SQL Server is not configured for remote access. Ask your system administrator to reconfigure SQL Server to allow remote access. I've checked on both servers and they're configured to allow remote connections. The login that I've

Excel Get External data from Sql Server: Excel Column order rearranged

☆樱花仙子☆ 提交于 2019-12-07 19:11:00
问题 I created a views on sql server with the following column order: Below are orders of the column when I select the view vwTable Shift_id | Client_ip | Machine_Center but when I'm going to select the views using get external data from the excel: SELECT * FROM vwTable The order of the column on EXCEL is not the same, the output is: Machine_Center | Client_ip | Shift_id Screenshots: from SSMS: Select * from vwTable from excel: get external data Select * from vwTable My problem is that the column

SQL Server Linked Server to Microsoft Access

家住魔仙堡 提交于 2019-12-07 08:02:15
问题 I have tried to make use of linked servers in SQL Server 2008 by doing the following to access a Microsoft Access 2003 Table. EXEC sp_addlinkedserver access1t, 'OLE DB Provider for Jet', 'Microsoft.Jet.OLEDB.4.0', 'C:\tester.mdb' EXEC sp_addlinkedsrvlogin access1t, FALSE, Null, Admin, Null GO CREATE VIEW TI001APCE1265 AS SELECT * FROM access1t...Table1 However, I get the error: OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "access1t" returned message "Unspecified error". Msg

SQL Linked server - Remote access error when executing SP

放肆的年华 提交于 2019-12-06 15:00:28
I've set up a linked server between an instance on SQL 2012 and SQL 2008R2 but I keep getting the below error when trying to execute a stored procedure on a remote server: Msg 7201, Level 17, State 4, Line 1 Could not execute procedure on remote server 'TEST' because SQL Server is not configured for remote access. Ask your system administrator to reconfigure SQL Server to allow remote access. I've checked on both servers and they're configured to allow remote connections. The login that I've used has sysadmin access on the remote server and I can see all the databases when I expand 'Catalogs'

OPENDATASOURCE instead of Linked Server

江枫思渺然 提交于 2019-12-06 11:29:05
I have a situation where a linked server to an access DB is crashing my SQL server. Crashed here means adding the linked server causes all other linked servers using that provider to stop working. Any queries to those linked servers hang and don't complete. This situation persists until the server is restarted. However, when I use OPENDATASOURCE to connect to the same data source I don't have this problem. Why would one work and the other crash? The provider I'm using is Microsoft.ACE.OLEDB.12.0. I have Dynamic parameter and Allow inprocess enabled. Example query below select * from