Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert into linked server using OPENQUERY

Posted on 2009-03-31
3
Medium Priority
?
5,839 Views
Last Modified: 2012-05-06
Im trying to create a stored procedure that inserts into table (on a linked server) using OpenQuery and Im getting following error.

OLE DB error trace [OLE/DB Provider 'MSDASQL' IUnknown::QueryInterface returned 0x80004002].
Msg 7390, Level 16, State 1, Line 1
The requested operation could not be performed because the OLE DB provider 'MSDASQL' does not support the required transaction interface.

Tried Select from same table using OpenQuery and it works fine. Linked server that Im trying to access is Informix on Linux.
Any idea what might be the problem?

DECLARE @sql1   VARCHAR(750), @sql2   VARCHAR(750), @sql3   VARCHAR(1000), @sql4   VARCHAR(1200)
declare @appl as varchar(5), @scf as varchar(3),@day_no varchar(1), @w_day varchar(2), @time_slot varchar(5), @tim_ampm varchar(2)
 
set @appl = 'COAT'
set @scf = '935'
set @day_no = '1'
set @w_day = 'MO'
set @time_slot = '10:00'
set @tim_ampm  ='AM' 
	
		set @sql1 = 'insert into OPENQUERY(NOBLE, '''
		set @sql2 = 'select appl, office_code, day_no, w_day, time_slot, time_ampm, slot_count from appt_setup'')'
		set @sql3 = ' values ('''
						+ @appl+''','''
						+ convert(varchar(3),@scf) + ''','''
						+ convert(varchar(2),@day_no) + ''','''
						+ @w_day + ''','''
						+ @time_slot + ''','''
						+ @tim_ampm + ''', 0)'
		set @sql4 = @sql1+ @sql2+@sql3
		exec (@sql4)

Open in new window

0
Comment
Question by:Jesus Rodriguez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Expert Comment

by:ralmada
ID: 24035107
Have you added the linked server using sp_addlinkedserver sp?
More reference on this here:
http://msdn.microsoft.com/en-us/library/ms190479(SQL.90).aspx 
0
 
LVL 41

Accepted Solution

by:
ralmada earned 800 total points
ID: 24035165
Also in Management Studio, go to Server Objects -> Linked Servers->Providers and right click on MSDASQL. Make sure that the Provider Option "Non transacted updates" is ticked.
0
 
LVL 13

Author Closing Comment

by:Jesus Rodriguez
ID: 31565114
Thanks ralmada, you are prompt and right to the point.
I checked the option Non transacted updates now my query works fine and I was able to insert records.
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question