call/exec a Stored Procedure from a View

  • Hi,

    is there a way, to call/exec a Stored Procedure from a View (SQLS 2008/R2)?

    😉

    Thanks and Best Regards

    Nicole

  • I tell you Why? ... There are a few front-end programs that can run only views - but unfortunately no SP.

    That's all...

  • No, it's not possible.

  • depending on what the procedure was doing, you might be able duplicate the logic from the proc in a view by using a CTE or two, but again it really depends on what the proc was doing.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Sounds like they're using entity framework and only use the views. Well another option is to create a table and populate it w/ the data u want then select from it using a view. How often u will need to insert/update/delete would depend on how often the data changes of course. If you're using sql server 2008 you can play w the merge statment for manipulating the data in said table.

  • also, a view can use or call a function, so if the proc can be converted to a function, that is another option.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (3/28/2012)


    also, a view can use or call a function, so if the proc can be converted to a function, that is another option.

    Performance however becomes, uhm, bad, from my experience.

    Had one of my developers do that here, rewrote it to not use a function in the view but expand the code out and took run time on a report from 2 days to about 10 minutes.

  • Anders Pedersen (3/28/2012)


    Lowell (3/28/2012)


    also, a view can use or call a function, so if the proc can be converted to a function, that is another option.

    Performance however becomes, uhm, bad, from my experience.

    Had one of my developers do that here, rewrote it to not use a function in the view but expand the code out and took run time on a report from 2 days to about 10 minutes.

    yeah absolutely! , the functions GOT to be rewritten as an inline table value function;

    otherwise if it's scalar or not inline, performance can bite you in the ...um... well wherever performance hurts.

    i've been trying to make it a habit of writing only inline table value functions.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply