Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call a Stored procedure in a view

Status
Not open for further replies.

ro1016

Programmer
Mar 30, 2006
13
US
Hi everybody,

I was wondering if you can call a stored procedure that has
one IN parameter in a view. And if yes what is the syntax for that?


Thank you!
 
Reading Books Online topic CREATE VIEW, I find that a view may be created with a SELECT statement only.

Unlike the INSERT which may use

EXECUTE stored_procedure @parameters

to load rows into a table. This might be useful depending on what you need to do with the VIEW. For instance, you could create a temporary table in a stored procedure and insert rows using another stored procedure as the source.
Code:
CREATE PROCEDURE proc_search_nursery_stock (
   @searchFor VARCHAR(55)
)

AS

CREATE TABLE #results (id INT, plant_name VARCHAR(255))

INSERT #results (id, plant_name)
EXECUTE proc_list_mature_plants_of_type @searchFor

SELECT * FROM #results



Not sure what you mean by an IN parameter, INPUT parameter perhaps?
 
Are you perhaps refering to an IN clause?

ie: Select .... from table Where column IN('A','B','C')
 
Thank you for your answers guys.
The reason I wanted to do that is I need to create metadata
off of a stored procedure with one IN Parameter in
WebFocus and it would not let me do that.As long as there
is no parameter coming in or out it's fine but it goes
crazy with parameters. So I thought may be one way around
it would be creating a view that calls the stored
procedure.

Thanks again for all your inputs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top