linked-server

SQL Server 2000 - Linked Server

泄露秘密 提交于 2019-11-28 02:12:08
问题 For our application, we using SQL Server 2000 & MySQL. I want to update the MySQL database if any modifications in SQL Server 2000. For this, I have created the Linked Server for MySQL. It works fine, but inside the trigger it shows the error message like [OLE/DB provider returned message: [MySQL][ODBC 3.51 Driver]Optional feature not supported] Msg 7391, Level 16, State 1, Procedure , Line 6 The operation could not be performed because the OLE DB provider 'MSDASQL' was unable to begin a

MSDTC on server 'server is unavailable

为君一笑 提交于 2019-11-27 19:36:38
I get this weird error on SQL Server. And I cannot find solution in older posts. I have this procedure: create proc _upJM_SyncAll_test as begin DECLARE @SQLString nvarchar(max) set @SQLString = N' DELETE FROM OPENQUERY([LOCAL_MYSQL],''SELECT acSubject FROM _utjm_setitemprices'') where acSubject not in (select acSubject from _uvJM_SetSubj) DELETE FROM OPENQUERY([LOCAL_MYSQL],''SELECT acSubject FROM _utjm_setsubj'') where acSubject not in (select acSubject from _uvJM_SetSubj) update a set acName2 = b.acName2, acName3 = b.acName3, acAddress = b.acAddress, acPost = b.acPost, acPostName = b

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

心不动则不痛 提交于 2019-11-27 19:36:13
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 ? 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].[table] In your example: select * from [test].[testdb].[dbo].[table] In SQL Server 2012 and above, you don't

Is there an “IF EXISTS” test for a linked server?

感情迁移 提交于 2019-11-27 15:59:02
I want to be able to programmatically (in T-SQL) check if a specific linked server already exists for my current server and database (so that if the link doesn't exist yet, I can create it). I tried stuff like this: IF OBJECT_ID('myserver\devdb_1') IS NULL BEGIN PRINT 'Does not exist, need to create link' EXEC master.dbo.sp_addlinkedserver @server = N'myserver\devdb_1', @srvproduct=N'SQL Server' END ELSE PRINT 'Link already exists' But the OBJECT_ID test always returns null, even if the link already exists. Any way to do this check in T-SQL, so that the rest of my code can assume the link

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

我是研究僧i 提交于 2019-11-27 13:36:28
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'[username]', @rmtpassword = '[password]' GO As specified in ckarst second link, there is a solution that works

Best way to get identity of inserted row in Linked server?

感情迁移 提交于 2019-11-27 06:41:58
问题 I am inserting record in a remote Sql Server using Linked server, Now I wanna get the id of inserted record. something like scope_identity() in local server. My remote sql server is 2000 version. I have seen this post but I can't add any stored procedures in remote sql server 回答1: You could use the remote side's sp_executesql : DECLARE @ScopeIdentity (ID int); INSERT INTO @ScopeIdentity EXEC server .master..sp_executesql N' INSERT INTO database . schema . table ( columns ) VALUES ( values );

How to find a text inside SQL Server procedures / triggers?

十年热恋 提交于 2019-11-27 04:55:44
问题 I have a linkedserver that will change. Some procedures call the linked server like this: [10.10.100.50].dbo.SPROCEDURE_EXAMPLE . We have triggers also doing this kind of work. We need to find all places that uses [10.10.100.50] to change it. In SQL Server Management Studio Express, I didn't find a feature like "find in whole database" in Visual Studio. Can a special sys-select help me find what I need? 回答1: here is a portion of a procedure I use on my system to find text.... DECLARE @Search

SQL Server: How to call a user-defined function (UDF) on linked server?

给你一囗甜甜゛ 提交于 2019-11-27 03:55:02
问题 i'm trying to call a User-Defined Function (UDF) on a linked server: CREATE FUNCTION [dbo].[UserGroupMembershipNames](@UserGUID uniqueidentifier) RETURNS VARCHAR(8000) AS BEGIN RETURN ASILIVE.ReportManager.dbo.UserGroupMembershipNames(@UserGUID) END This doesn't work, as documented in PRB: User-Defined Function Call in Four-Part Linked Server Query Fails with Error Message 170. They also give a workaround: For example, instead of the following query Select * from Linked_Server.northwind.dbo

MSDTC on server 'server is unavailable'

三世轮回 提交于 2019-11-26 19:56:08
问题 I get this weird error on SQL Server. And I cannot find solution in older posts. I have this procedure: create proc _upJM_SyncAll_test as begin DECLARE @SQLString nvarchar(max) set @SQLString = N' DELETE FROM OPENQUERY([LOCAL_MYSQL],''SELECT acSubject FROM _utjm_setitemprices'') where acSubject not in (select acSubject from _uvJM_SetSubj) DELETE FROM OPENQUERY([LOCAL_MYSQL],''SELECT acSubject FROM _utjm_setsubj'') where acSubject not in (select acSubject from _uvJM_SetSubj) update a set

Is there an “IF EXISTS” test for a linked server?

时光怂恿深爱的人放手 提交于 2019-11-26 17:22:57
问题 I want to be able to programmatically (in T-SQL) check if a specific linked server already exists for my current server and database (so that if the link doesn't exist yet, I can create it). I tried stuff like this: IF OBJECT_ID('myserver\devdb_1') IS NULL BEGIN PRINT 'Does not exist, need to create link' EXEC master.dbo.sp_addlinkedserver @server = N'myserver\devdb_1', @srvproduct=N'SQL Server' END ELSE PRINT 'Link already exists' But the OBJECT_ID test always returns null, even if the link