linked-server

Calling an Oracle function from SQL Server Linked Server

柔情痞子 提交于 2019-12-20 02:52:15
问题 I have setup a linked server pointing to an Oracle DB. I want to call a function ABC in a package XYZ passing parameter K. What will be the syntax to do this? 回答1: I used the following syntax and it worked for me. EXECUTE (Query, Parameters) AT LinkedServerName Example: EXECUTE ( 'BEGIN ? := Package.MyFunction(?,?); END;', @ReturnValue, @InputPara, @OutputPara OUTPUT ) AT LinkedServerName Important Points: Don't forget the BEGIN and END syntax when calling functions Don't forget the semicolon

TRY CATCH with Linked Server in SQL Server 2005 Not Working

懵懂的女人 提交于 2019-12-20 01:55:07
问题 I am trying to catch sql error raised when I execute a stored procedure on a linked server. Both Servers are running SQL Server 2005. To prove the issue I have created a stored procedure on the linked server called Raise error that executes the following code: RAISERROR('An error', 16, 1); If I execute the stored procedure directly on the linked server using the following code I get a result set with 'An error', '16' as expected (ie the code enters the catch block): BEGIN TRY EXEC [dbo].

Linked Server failing on SQL Server job

北城余情 提交于 2019-12-19 22:12:12
问题 I have a linked server that perfectly works when executing a query. But when I place the query in a job, it fails. Here is the setting of my linked server Error 回答1: Read SQL Server Agent job fails when the job uses a linked server. WORKAROUND To work around this problem, use one of the following methods: Method 1 Make the system administrator the owner of the job . Method2: Use mapped security context for the linked server and modify the job to run as OSQL. To set the mapped security context

Linked Server failing on SQL Server job

眉间皱痕 提交于 2019-12-19 22:11:08
问题 I have a linked server that perfectly works when executing a query. But when I place the query in a job, it fails. Here is the setting of my linked server Error 回答1: Read SQL Server Agent job fails when the job uses a linked server. WORKAROUND To work around this problem, use one of the following methods: Method 1 Make the system administrator the owner of the job . Method2: Use mapped security context for the linked server and modify the job to run as OSQL. To set the mapped security context

How to execute store procedure for another DB?

痞子三分冷 提交于 2019-12-19 18:18:46
问题 I have a stored procedure that should be able to be executed on any table of any database on my MS Sql Server. Most of the combination of EXEC and USE statements didn't result in anything. Here is the stored procedure: CREATE PROCEDURE [dbo].[usp_TrimAndLowerCaseVarcharFields] ( @Database VARCHAR(200), @TableSchema VARCHAR(200), @TableName VARCHAR(200) ) AS BEGIN DECLARE @sSql VARCHAR(MAX) SET @Database = '[' + @Database + ']' SET @sSql = '' -- Create first part of a statement to update all

Transaction context in use by another session

北慕城南 提交于 2019-12-19 05:19:26
问题 I have a table called MyTable on which I have defined a trigger, like so: CREATE TRIGGER dbo.trg_Ins_MyTable ON dbo.MyTable FOR INSERT AS BEGIN SET NOCOUNT ON; insert SomeLinkedSrv.Catalog.dbo.OtherTable (MyTableId, IsProcessing, ModifiedOn) values (-1, 0, GETUTCDATE()) END GO Whenever I try to insert a row in MyTable , I get this error message: Msg 3910, Level 16, State 2, Line 1 Transaction context in use by another session. I have SomeLinkedSrv properly defined as a linked server (for

Linked Server Insert-Select Performance

僤鯓⒐⒋嵵緔 提交于 2019-12-18 16:51:32
问题 Assume that I have a table on my local which is Local_Table and I have another server and another db and table, which is Remote_Table (table structures are the same). Local_Table has data, Remote_Table doesn't. I want to transfer data from Local_Table to Remote_Table with this query: Insert into RemoteServer.RemoteDb..Remote_Table select * from Local_Table (nolock) But the performance is quite slow. However, when I use SQL Server import-export wizard, transfer is really fast. What am I doing

Linked Server Insert-Select Performance

情到浓时终转凉″ 提交于 2019-12-18 16:51:15
问题 Assume that I have a table on my local which is Local_Table and I have another server and another db and table, which is Remote_Table (table structures are the same). Local_Table has data, Remote_Table doesn't. I want to transfer data from Local_Table to Remote_Table with this query: Insert into RemoteServer.RemoteDb..Remote_Table select * from Local_Table (nolock) But the performance is quite slow. However, when I use SQL Server import-export wizard, transfer is really fast. What am I doing

How to add an IBM DB2 server to SQL Server's Linked Server

百般思念 提交于 2019-12-18 13:36:41
问题 From .Net, I'm able to connect to the DB2 database: First I include a reference to "IBM.Data.DB2.iSeries" Then I create a new IBM.Data.DB2.iSeries.iDB2Connection. The connection string is DataSource=ChaDb2Server;UserID=MyUsername;Password=MyPassword; Then I create an IBM.Data.DB2.iSeries.iDB2Command, and so on. Now I'm trying to get my SQL Server 2005 to access the same data directly. In SQL Server Management Studio, I right-click on Linked Servers, and select "New Linked Server..." Linked

sql server linked server to oracle returns no data found when data exists

感情迁移 提交于 2019-12-18 08:10:06
问题 I have a linked server setup in SQL Server to hit an Oracle database. I have a query in SQL Server that joins on the Oracle table using dot notation. I am getting a “No Data Found” error from Oracle. On the Oracle side, I am hitting a table (not a view) and no stored procedure is involved. First, when there is no data I should just get zero rows and not an error. Second, there should actually be data in this case. Third, I have only seen the ORA-01403 error in PL/SQL code; never in SQL. This