linked-server

SQL - Connect to Linked Server with Named Instance

帅比萌擦擦* 提交于 2019-12-18 07:01:48
问题 How do I connect to a named instance of a linked SQL server. If its not linked, I would do the following: ServerName.DatabaseName.dbo.TableName If it is linked, I would assume the following: ServerName\InstanceName.DatabaseName.dbo.TableName but SQL doesn't like the "\" What is the correct syntax 回答1: Check this You can surround server name with brackets 回答2: the correct syntax is [ServerName\InstanceName].DatabaseName.dbo.TableName . 回答3: If you are using the default instance, you don't need

Could not find server 'server name' in sys.servers. SQL Server 2014

人盡茶涼 提交于 2019-12-18 05:41:53
问题 I recently upgraded our SQL Server from 2005 to 2014 (linked server) and I am noticing that one of the stored procedures which calls the exec command to execute a stored procedure on the upgraded linked server is failing with the error Could not find server 'server name' in sys.servers.Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers. The issue is that the linked server exists and I have done

Could not find server 'server name' in sys.servers. SQL Server 2014

二次信任 提交于 2019-12-18 05:41:46
问题 I recently upgraded our SQL Server from 2005 to 2014 (linked server) and I am noticing that one of the stored procedures which calls the exec command to execute a stored procedure on the upgraded linked server is failing with the error Could not find server 'server name' in sys.servers.Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers. The issue is that the linked server exists and I have done

Can you have a Foreign Key onto a View of a Linked Server table in SQLServer 2k5?

瘦欲@ 提交于 2019-12-18 04:19:12
问题 I have a SQLServer with a linked server onto another database somewhere else. I have created a view on that linked server create view vw_foo as select [id], [name] from LINKEDSERVER.RemoteDatabase.dbo.tbl_bar I'd like to to the following alter table [baz] add foo_id int not null go alter table [baz] with check add constraint [fk1_baz_to_foo] foreign key([foo_id]) references [dbo].[vw_foo] ([id]) go But that generates the error: "Foreign key 'fk1_baz_to_foo' references object 'dbo.vw_foo'

Calling Oracle stored procedure with output parameter from SQL Server

回眸只為那壹抹淺笑 提交于 2019-12-18 02:35:05
问题 I have an Oracle linked server in SQL Server 2008 R2. I need to execute Oracle stored procedures (with output parameter in first, and input parameter in second procedure): CREATE OR REPLACE PROCEDURE my1.spGetDate(CurrentDate OUT VARCHAR2) IS BEGIN -- set output parameter, no select statements END; CREATE OR REPLACE PROCEDURE my1.spDeleteOldRecords(CurrentDate IN VARCHAR2) IS BEGIN -- conditional delete from oracle table, no select statements END; I didn't found any complete documentation on

Querying a linked sql server

风流意气都作罢 提交于 2019-12-17 22:46:11
问题 I added a linked server, which is showing in the linked server list, but when I query it, it throws an error with the db server name. EXEC sp_helpserver EXEC sp_addlinkedserver 'aa-db-dev01' Select * from openquery('aa-db-dev01','Select * from TestDB.dbo.users') Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'aa-db-dev01'. 回答1: SELECT * FROM [server].[database].[schema].[table] This works for me. SSMS intellisense may still underline this as a syntax error, but it should work if

How to select data of a table from another database in SQL Server?

∥☆過路亽.° 提交于 2019-12-17 15:46:11
问题 Suppose, I have a database named testdb in test server . Also I have a database named proddb in prod server. Now I want to select data of a table of testdb database from proddb database. How can I do that in SQL Server ? Also, I can do it using database link in oracle . But how can do that in SQL Server ? 回答1: You need sp_addlinkedserver() http://msdn.microsoft.com/en-us/library/ms190479.aspx Example: exec sp_addlinkedserver @server = 'test' then select * from [server].[database].[schema].

Why do I get the error “Xml data type is not supported in distributed queries” when querying a linked server for non-xml data?

試著忘記壹切 提交于 2019-12-17 10:33:31
问题 I have two SQL Servers (running SQL Server 2008) named DATA01 and DATA02 . DATA02 has a linked server definition LINK , that points at DATA01 , with suitable user mapping set up. On DATA01 there is a database MyDatabase containing these two tables: CREATE TABLE T_A ( Id int ) CREATE TABLE T_B ( Id int, Stuff xml ) When I run this command from DATA02 , I get data returned as expected: SELECT Id FROM LINK.MyDatabase.dbo.T_A; However, when I run this command from DATA02 , I get an error: SELECT

I need to add a linked server to a MS Azure SQL Server

末鹿安然 提交于 2019-12-17 09:39:55
问题 I have tried and tried, and can not get linked. I can connect to the server using SSMS, but can not link to it from a local server. Here is my script (replacing things in brackets with pertainent information): EXEC master.dbo.sp_addlinkedserver @server = N'[servername].database.windows.net', @srvproduct = N'Any', @provider = N'MSDASQL', @datasrc = N'Azure_ODBC1' GO EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'[servername]', @useself = N'False', @locallogin = NULL, @rmtuser = N'

SQL IF block code causing error even though it shouldn't execute

跟風遠走 提交于 2019-12-14 03:52:59
问题 I have a case in which I have SQL code with an IF-ELSE block. The code in the IF portion should not be reached, but I still get an error when the SQL executes. In the code I first test for the linked server, and when that fails, @reval is set to 1 and the ELSE block should execute and avoid the code in the IF block that needs to query the linked server, but I get this error: Msg -1, Level 16, State 1, Line 0 SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].