January 23rd, 2004, 03:01 AM
Execute stored proceedure from SP
Hi all i am attempting to Execute a stored procedure (SP2) From within a stored procedure (SP1). This works fine if i assign a value to the variable in SP2 but when i use the query an Internal SQL Server Error occurs.
Below is SP2 and then the execute line from SP1
CREATE PROCEDURE SP2
@CountRatio INT OUTPUT
SET @CountRatio = (SELECT COUNT(Ratio) FROM RatioReport WHERE IP_ID= @IP_ID and Network= @Network and Ratio=0)
The Execute line in SP1 is
EXEC SP2 @IP_ID,@Network,@CountRatio OUTPUT
I am stumped as to why it will not return a value using the query, i have tested the query and that works fine, any ideas?
January 23rd, 2004, 09:45 AM
i have worked out the problem, it is because in the SP2 the query:
(SELECT COUNT(Ratio) FROM RatioReport WHERE IP_ID= @IP_ID and Network= @Network and Ratio=0)
is on a view.
I have transfered the data into a table and it works fine when i query the table but this is not a perminent option
is it possible to query a view from within this stored procedure?
January 23rd, 2004, 08:08 PM
Just query the view as you would any other table
select * from my_view
where blah = @Blah
<%Questions of Science%>