all groups > sql server programming > july 2007 >
You're in the

sql server programming

group:

OPENROWSET to return the results of stored procedure


OPENROWSET to return the results of stored procedure aron
7/10/2007 8:19:51 PM
sql server programming:
I'm getting the following error when trying to call a stored procedure
with parameters as a table in a select statement:
Server: Msg 7357, Level 16, State 1, Line 1
Cannot process the object ....... The OLE DB provider "SQLNCLI" for
linked server "(null)" indicates that either the object has .........

Here is my sql statement:
select *
FROM OPENROWSET
('SQLNCLI','server=<srvr>;Trusted_Connection=yes;','SET FMTONLY
OFF;exec <server>.(database>.dbo.<storedprocedure> ''<string
parameter>'',<int parameter1>,<int parameter2>'
)
AS tbl
Re: OPENROWSET to return the results of stored procedure Erland Sommarskog
7/10/2007 10:56:03 PM
aron (aron.felberbaum@gmail.com) writes:
[quoted text, click to view]

Why not run the procedure with a four-part form:

EXEC Server.database.dbo.storedprocedure

If you need to use the result in a query, user INSERT-EXEC. The SET FMTONLY
trick is not without problems - it means that the procedure is executed
twice.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: OPENROWSET to return the results of stored procedure aron
7/11/2007 12:00:00 AM
[quoted text, click to view]

Tried the following and I'm getting the same error
select * FROM OPENROWSET
('SQLNCLI','server=srvr;Trusted_Connection=yes;','exec
Server.database.dbo.storedprocedure ''xxxxx'',999,-99') AS tbl
Re: OPENROWSET to return the results of stored procedure Erland Sommarskog
7/11/2007 2:40:34 PM
aron (aron.felberbaum@gmail.com) writes:
[quoted text, click to view]

If it wasn't clear from my post: you should not use OPENROWSET at all.
Just call the procedure in a regular EXEC statement.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
AddThis Social Bookmark Button