Link to home
Start Free TrialLog in
Avatar of Jesus Rodriguez
Jesus RodriguezFlag for United States of America

asked on

Insert into linked server using OPENQUERY

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

Avatar of ralmada
ralmada
Flag of Canada image

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 
ASKER CERTIFIED SOLUTION
Avatar of ralmada
ralmada
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jesus Rodriguez

ASKER

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.