[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Execute store procedure with Openquery

Posted on 2009-06-29
3
Medium Priority
?
2,135 Views
Last Modified: 2012-05-07
Hello,

I have created a linked server between an sql server 2000 and sql server 2005 express, named svr02\svr02

In the linked server svr02 i have create a simple Stored Procedure 'sp_CreateOrder' with no parameters which inserts a row into a test table 'Orders'. This stored procedure works from the second server svr02.

I'm trying to use this from the first server using openquery
SELECT * FROM OPENQUERY([svr02\svr02], 'Order.dbo.sp_CreateOrder');

this gives the following error
OLE DB error trace [Non-interface error:  OLE DB provider unable to process object, since the object has no columnsProviderName='SQLOLEDB', Query=Order.dbo.sp_CreateOrder'].
Msg 7357, Level 16, State 2, Line 1
Could not process object 'Order.dbo.sp_CreateOrder'. The OLE DB provider 'SQLOLEDB' indicates that the object has no columns.

Openquery works fine when i do select statements.

Thank you
Teo
0
Comment
Question by:temmelv
[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 31

Expert Comment

by:RiteshShah
ID: 24743038
what is your database name? Is it "Order"?
0
 
LVL 31

Accepted Solution

by:
RiteshShah earned 1500 total points
ID: 24743071
if you have add linked server and wants to call it's stored procedure than you have to use following syntax

exec [svr02\svr02].[databaseName].dbo.sp_CreateOrder

use four part while calling SP. first is server name, second is database name which has your SP, third is owner name, and finally stored procedure name.
0
 

Author Comment

by:temmelv
ID: 24744153
This worked
exec [svr02\svr02].[databaseName].dbo.sp_CreateOrder

but is also needed

exec sp_serveroption @server='myserver', @optname='rpc', @optvalue='true'
exec sp_serveroption @server='myserver', @optname='rpc out', @optvalue='true'

Thank you.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

650 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