Unix Technical Forum

stored procedure

This is a discussion on stored procedure within the SQL Server forums, part of the Microsoft SQL Server category; --> I am trying to store the turn out of a stored procedure in a temporary table to make filters. ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 04:53 AM
Mónica
 
Posts: n/a
Default stored procedure

I am trying to store the turn out of a stored procedure in a temporary
table to make filters. I do it of the following way:

SELECT a.*
FROM OPENROWSET('SQLOLEDB', 'servidor';'user';'pwd' , 'EXEC
VERT_PERIODOS_CCV
''07/06/2003'',''31/12/2003'',''49'','''',''1'','''','''',''''') AS a

but it gives back the following error to me:

Servidor: mensaje 7357, nivel 16, estado 2, línea 1
No se puede procesar el objeto 'EXEC VERT_PERIODOS_CCV
'07/06/2003','31/12/2003','49','','1','','','''. El proveedor OLE DB
'SQLOLEDB' indica que el objeto no tiene columnas.
Traza de error de OLE DB [Non-interface error: OLE DB provider unable to
process object, since the object has no columnsProviderName='SQLOLEDB',
Query=EXEC VERT_PERIODOS_CCV
'07/06/2003','31/12/2003','49','','1','','','''].

Somebody knows why?

Thanks

Mónica




--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 04:54 AM
Erland Sommarskog
 
Posts: n/a
Default Re: stored procedure

[posted and mailed, please reply in news]

Mónica (mvpriede@hotmail.com) writes:
> I am trying to store the turn out of a stored procedure in a temporary
> table to make filters. I do it of the following way:
>
> SELECT a.*
> FROM OPENROWSET('SQLOLEDB', 'servidor';'user';'pwd' , 'EXEC
> VERT_PERIODOS_CCV
> ''07/06/2003'',''31/12/2003'',''49'','''',''1'','''','''',''''') AS a
>
> but it gives back the following error to me:
>
> Servidor: mensaje 7357, nivel 16, estado 2, línea 1
> No se puede procesar el objeto 'EXEC VERT_PERIODOS_CCV
> '07/06/2003','31/12/2003','49','','1','','','''. El proveedor OLE DB
> 'SQLOLEDB' indica que el objeto no tiene columnas.
> Traza de error de OLE DB [Non-interface error: OLE DB provider unable to
> process object, since the object has no columnsProviderName='SQLOLEDB',
> Query=EXEC VERT_PERIODOS_CCV
> '07/06/2003','31/12/2003','49','','1','','','''].
>
> Somebody knows why?


When you run a query through OPENROWSET or OPENQUERY, the query is in
fact run twice. First SQLOLEDB runs it with SET FMTONLY ON to detect
any results sets from the query, after which SQLOLEDB runs the query
with SET FMTONLY to actually execute it. In the mode FMTONLY ON, SQL
Server does not execute the statements, but just sifts through them
to find the result sets.

Unfortunately there are situations when SQL Server does not find any
result sets, and the most typical is when you create a temp table in
the procedure. Since the procedure is created in NOEXEC mode, the
table is not created, so there you go.

One way to cirumvent this is to use a table variable instead. This
should work, although I cannot recall whether I actually tested it.

You can also fool SQLOLEDB by adding SET FMTONLY OFF first to
the remote statement, but notice that this means that the procedure
is actually executed twice.

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

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:09 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com