Can i call stored procedure in a view
Sign up. By signing in, you agree to our Terms of Use and Privacy Policy. Already have an account? Sign in. By signing up, you agree to our Terms of Use and Privacy Policy.
Enter the email address associated with your account. We'll send a magic link to your inbox. Email Address. All Sign in options. Enter a Email Address. Choose your interests Get the latest news, expert insights and market research, sent straight to your inbox. Newsletter Topics Select minimum 1 topic.
It requires SQL Server to compose the business rationale with the different tables with information manipulation.
Essential standard conventions of comparing a procedure with functions are listed below:. SQL Server tabular function is a program that can be used to return data by joining the multiple tables. Essential standard conventions of comparing a function with the procedure are listed below;. If you do not specify the database in connection and query statement, then the query will return an error as below:.
Users can insert those rows into the temp table or table variable to process it further. The above samples include the number of scenarios of procedure integration with the function, including error handling. Now, it turns out to be simpler for the users who want to include this methodology in the existing database structure. In all of the above sample codes, the SQL Server instance name is used as a localhost because it performed each task on the local machine.
However, it should be the instance name of the SQL Server. If users want to execute the procedure on a remote server, then remote SQL Server name can be used instead of the localhost and that remote SQL Server instance name must exist in your linked servers list.
You would essentially write the results of your proc to a table var or temp table, then select into the view. Edit - If you can change your stored procedure to a Table Value function, it would eliminate the step of selecting to a temp table. Instead, convert your proc to a table-value function as mentioned in other posts and select from that:. Note that even if your MyTableValueFunction doesn't accept any parameters, you still need to include parentheses after it, i. Easiest solution that I might have found is to create a table from the data you get from the SP.
Then create a view from that:. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to call Stored Procedure in a View? Ask Question. Asked 12 years, 5 months ago. Active 3 years ago. Viewed k times. How would I call a Stored Procedure that returns data in a View? Is this even possible? Improve this question. Cade Roux Duplicate: stackoverflow. Add a comment. Active Oldest Votes.
0コメント