SELECT from SP

  • Thread starter Dimitris Nikolakakis
  • Start date
D

Dimitris Nikolakakis

I have a stored procedure named [ORD-qClientsOrders] and I want to create
another SP that SELECTS records from
[ORD-qClientsOrders].

The error is 'Invalid object name ORD-qClientsOrders.'

Thanks
Dimitris
 
D

dbahooker

a) don't put special characters in your objects
b) you can't select from a sproc.

if you NEED to reuse the logic; use a UDF; table valued most likely.

tell us more about what you need to do.

in general; if you can write it as a view instead of a sproc; then do
it.
then you can select from a view without a problem

-Aaron
 
S

Sylvain Lafontaine

Note easy: SP return resultsets (or recordsets), not tables or views and you
cannot select from a resultset directly. To do so, you must use OPENQUERY,
OPENROWSET, or OPENDATASOURCE to call the SP from another SP. These
procedures requires that you use a connection string to the server itself or
that you create a linked server, also pointing toward itself. See the BOL
for more info on these three functions.

The easiest and best solution for you is probably to convert your SP to a
View or a User Defined Function (UDF), which may be called directly from a
Select. Also, with UDF, you must often provide the full name including the
schema; ie. use dbo.MyUDF() instead of just MyUDF().

On the ADP side, to call a UDF as the record source of a form, you must use
a full SQL statement and not just the name (as you would do for a SP):

Select * from MyUDF()
 
D

dbahooker

and from what i've seen; i try to always prefix functions with the
dbo.. it seems to get a little bit testy otherwise

-Aaron

Note easy: SP return resultsets (or recordsets), not tables or views and you
cannot select from a resultset directly. To do so, you must use OPENQUERY,
OPENROWSET, or OPENDATASOURCE to call the SP from another SP. These
procedures requires that you use a connection string to the server itself or
that you create a linked server, also pointing toward itself. See the BOL
for more info on these three functions.

The easiest and best solution for you is probably to convert your SP to a
View or a User Defined Function (UDF), which may be called directly from a
Select. Also, with UDF, you must often provide the full name including the
schema; ie. use dbo.MyUDF() instead of just MyUDF().

On the ADP side, to call a UDF as the record source of a form, you must use
a full SQL statement and not just the name (as you would do for a SP):

Select * from MyUDF()

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


Dimitris Nikolakakis said:
I have a stored procedure named [ORD-qClientsOrders] and I want to create
another SP that SELECTS records from
[ORD-qClientsOrders].

The error is 'Invalid object name ORD-qClientsOrders.'

Thanks
Dimitris
 
D

dbahooker

in other words, select * from dbo.MyUdf()

I would shy away from functions though; they're a little bit difficult
to work with; and i've had some compatability problems sometimes with
them.

I would reccomend the view route.

build a view the combines orders and orderDetails.. then when you
'select * from myOrders where OrderID = 12' then it usually does a
pretty good job internally

-Aaron

Note easy: SP return resultsets (or recordsets), not tables or views and you
cannot select from a resultset directly. To do so, you must use OPENQUERY,
OPENROWSET, or OPENDATASOURCE to call the SP from another SP. These
procedures requires that you use a connection string to the server itself or
that you create a linked server, also pointing toward itself. See the BOL
for more info on these three functions.

The easiest and best solution for you is probably to convert your SP to a
View or a User Defined Function (UDF), which may be called directly from a
Select. Also, with UDF, you must often provide the full name including the
schema; ie. use dbo.MyUDF() instead of just MyUDF().

On the ADP side, to call a UDF as the record source of a form, you must use
a full SQL statement and not just the name (as you would do for a SP):

Select * from MyUDF()

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


Dimitris Nikolakakis said:
I have a stored procedure named [ORD-qClientsOrders] and I want to create
another SP that SELECTS records from
[ORD-qClientsOrders].

The error is 'Invalid object name ORD-qClientsOrders.'

Thanks
Dimitris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

From MDB to ADP 1
How do I make one word have small caps? 2
# sign in field name exported as '.' 2
Numbering Records 5
VLookUp 1
Only if upper case 4
Find funtion in macro 5
IIf Help!!! again 2

Top