Re: a view based on stored procedure
From: Tom Moreau (tom_at_dont.spam.me.cips.ca)
Date: 03/17/04
- Next message: Rus Kehoe: "SQL recode"
- Previous message: Google Mike: "workaround: Sp_cursor: The Parameter 'Table' Is Invalid with Long Database Names"
- In reply to: Biva: "a view based on stored procedure"
- Next in thread: sqlgirl: "Re: a view based on stored procedure"
- Reply: sqlgirl: "Re: a view based on stored procedure"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 17 Mar 2004 14:47:39 -0500
To make a very long story short, put the following at the beginning of the
proc:
if (1 = 2)
select
Col1
, Col2
from
MyTable
... only modify it to have the exact same column names and positions as the
final SELECT in your query. Same goes for the table name. The optimizer
needs to be able to sniff the metadata for your result set and this is a
workaround.
--
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Biva" <biva.yauchler@redprairie.com> wrote in message
news:4058a9d2$0$38876$39cecf19@news.twtelecom.net...
Hello All,
SQL 2K w/ SP3a
I am trying to create a view based on a stored procedure so I can use that
view in Crystal Reports.
When I execute the stored procedure in Query Analyzer, it returns 1083 rows
without an error.
I am trying to create the view using the following select statement:
SELECT * FROM OPENROWSET('SQLOLEDB.1',
'DRIVER={SQL Server};SERVER=gorilla;Database=Corp;UID=fin;PWD=acct',
'EXEC rp_ResAvailPlanInfo')
When I execute the above statement from Query Analyzer, I get the following
error:
Could not process object 'EXEC rp_ResAvailPlanInfo'. The OLE DB provider
'SQLOLEDB.1' indicates that the object has no columns.
OLE DB error trace [Non-interface error: OLE DB provider unable to process
the object:ProviderName='SQLOLEDB.1', Query=EXEC rp_ResAvailPlanInfo'].
In the stored procedure, I am selecting data from 2 views, opening a cursor,
inserting data into a permanent table and selecting data from that permanent
table.
All columns are named.
Any help in this matter would be greatly appreciated.
Thanks,
sqlgirl
- Next message: Rus Kehoe: "SQL recode"
- Previous message: Google Mike: "workaround: Sp_cursor: The Parameter 'Table' Is Invalid with Long Database Names"
- In reply to: Biva: "a view based on stored procedure"
- Next in thread: sqlgirl: "Re: a view based on stored procedure"
- Reply: sqlgirl: "Re: a view based on stored procedure"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|